aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/debugger/debugger.pri2
-rw-r--r--src/qml/debugger/qqmlconfigurabledebugservice.cpp16
-rw-r--r--src/qml/debugger/qqmldebug.cpp120
-rw-r--r--src/qml/debugger/qqmldebugconnector.cpp120
-rw-r--r--src/qml/debugger/qqmldebugconnector_p.h2
-rw-r--r--src/qml/debugger/qqmldebugserver.cpp214
-rw-r--r--src/qml/debugger/qqmlprofilerservice.cpp13
-rw-r--r--src/qml/qml/qqmlengine.cpp24
8 files changed, 348 insertions, 163 deletions
diff --git a/src/qml/debugger/debugger.pri b/src/qml/debugger/debugger.pri
index d6fb02a122..cbb1646ff6 100644
--- a/src/qml/debugger/debugger.pri
+++ b/src/qml/debugger/debugger.pri
@@ -1,6 +1,8 @@
contains(QT_CONFIG, no-qml-debug):DEFINES += QT_NO_QML_DEBUGGER
SOURCES += \
+ $$PWD/qqmldebug.cpp \
+ $$PWD/qqmldebugconnector.cpp \
$$PWD/qqmldebugservice.cpp \
$$PWD/qqmlprofilerservice.cpp \
$$PWD/qqmldebugserver.cpp \
diff --git a/src/qml/debugger/qqmlconfigurabledebugservice.cpp b/src/qml/debugger/qqmlconfigurabledebugservice.cpp
index 32dda87937..aa5e69b63d 100644
--- a/src/qml/debugger/qqmlconfigurabledebugservice.cpp
+++ b/src/qml/debugger/qqmlconfigurabledebugservice.cpp
@@ -39,11 +39,19 @@ QT_BEGIN_NAMESPACE
QQmlConfigurableDebugService::QQmlConfigurableDebugService(const QString &name, float version,
QObject *parent) :
- QQmlDebugService((*new QQmlConfigurableDebugServicePrivate(name, version)), parent) { init(); }
+ QQmlDebugService((*new QQmlConfigurableDebugServicePrivate(name, version)), parent)
+{
+ registerService();
+ init();
+}
QQmlConfigurableDebugService::QQmlConfigurableDebugService(QQmlDebugServicePrivate &dd,
QObject *parent) :
- QQmlDebugService(dd, parent) { init(); }
+ QQmlDebugService(dd, parent)
+{
+ registerService();
+ init();
+}
QMutex *QQmlConfigurableDebugService::configMutex()
{
@@ -56,7 +64,7 @@ void QQmlConfigurableDebugService::init()
Q_D(QQmlConfigurableDebugService);
QMutexLocker lock(&d->configMutex);
// If we're not enabled or not blocking, don't wait for configuration
- d->waitingForConfiguration = (registerService() == Enabled &&
+ d->waitingForConfiguration = (state() == Enabled &&
QQmlDebugConnector::instance()->blockingMode());
}
@@ -74,6 +82,8 @@ void QQmlConfigurableDebugService::stateChanged(QQmlDebugService::State newState
{
if (newState != Enabled)
stopWaiting();
+ else
+ init();
}
void QQmlConfigurableDebugService::engineAboutToBeAdded(QQmlEngine *engine)
diff --git a/src/qml/debugger/qqmldebug.cpp b/src/qml/debugger/qqmldebug.cpp
new file mode 100644
index 0000000000..83718921f1
--- /dev/null
+++ b/src/qml/debugger/qqmldebug.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmldebug.h"
+#include "qqmldebugconnector_p.h"
+
+#include <private/qqmlengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+QQmlDebuggingEnabler::QQmlDebuggingEnabler(bool printWarning)
+{
+#ifndef QQML_NO_DEBUG_PROTOCOL
+ if (!QQmlEnginePrivate::qml_debugging_enabled
+ && printWarning) {
+ qDebug("QML debugging is enabled. Only use this in a safe environment.");
+ }
+ QQmlEnginePrivate::qml_debugging_enabled = true;
+#else
+ Q_UNUSED(printWarning);
+#endif
+}
+
+/*!
+ * \enum QQmlDebuggingEnabler::StartMode
+ *
+ * Defines the debug server's start behavior. You can interrupt QML engines starting while a debug
+ * client is connecting, in order to set breakpoints in or profile startup code.
+ *
+ * \value DoNotWaitForClient Run any QML engines as usual while the debug services are connecting.
+ * \value WaitForClient If a QML engine starts while the debug services are connecting,
+ * interrupt it until they are done.
+ */
+
+/*!
+ * Enables debugging for QML engines created after calling this function. The debug server will
+ * listen on \a port at \a hostName and block the QML engine until it receives a connection if
+ * \a mode is \c WaitForClient. If \a mode is not specified it won't block and if \a hostName is not
+ * specified it will listen on all available interfaces. You can only start one debug server at a
+ * time. A debug server may have already been started if the -qmljsdebugger= command line argument
+ * was given. This method returns \c true if a new debug server was successfully started, or
+ * \c false otherwise.
+ */
+bool QQmlDebuggingEnabler::startTcpDebugServer(int port, StartMode mode, const QString &hostName)
+{
+#ifndef QQML_NO_DEBUG_PROTOCOL
+ QQmlDebugConnector::setPluginKey(QLatin1String("QQmlDebugServer"));
+ QQmlDebugConnector *connector = QQmlDebugConnector::instance();
+ if (connector) {
+ QVariantHash configuration;
+ configuration[QLatin1String("portFrom")] = configuration[QLatin1String("portTo")] = port;
+ configuration[QLatin1String("block")] = (mode == WaitForClient);
+ configuration[QLatin1String("hostAddress")] = hostName;
+ return connector->open(configuration);
+ }
+#else
+ Q_UNUSED(port);
+ Q_UNUSED(block);
+ Q_UNUSED(hostName);
+#endif
+ return false;
+}
+
+/*!
+ * Enables debugging for QML engines created after calling this function. The debug server will
+ * connect to a debugger waiting on a local socket at the given \a socketFileName and block the QML
+ * engine until the connection is established if \a mode is \c WaitForClient. If \a mode is not
+ * specified it will not block. You can only start one debug server at a time. A debug server may
+ * have already been started if the -qmljsdebugger= command line argument was given. This method
+ * returns \c true if a new debug server was successfully started, or \c false otherwise.
+ */
+bool QQmlDebuggingEnabler::connectToLocalDebugger(const QString &socketFileName, StartMode mode)
+{
+#ifndef QQML_NO_DEBUG_PROTOCOL
+ QQmlDebugConnector::setPluginKey(QLatin1String("QQmlDebugServer"));
+ QQmlDebugConnector *connector = QQmlDebugConnector::instance();
+ if (connector) {
+ QVariantHash configuration;
+ configuration[QLatin1String("fileName")] = socketFileName;
+ configuration[QLatin1String("block")] = (mode == WaitForClient);
+ return connector->open(configuration);
+ }
+#else
+ Q_UNUSED(fileName);
+ Q_UNUSED(block);
+#endif
+ return false;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/debugger/qqmldebugconnector.cpp b/src/qml/debugger/qqmldebugconnector.cpp
new file mode 100644
index 0000000000..eb111f75d0
--- /dev/null
+++ b/src/qml/debugger/qqmldebugconnector.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmldebugpluginmanager_p.h"
+#include "qqmldebugconnector_p.h"
+#include "qdebugmessageservice_p.h"
+#include "qqmlenginecontrolservice_p.h"
+#include "qqmlenginedebugservice_p.h"
+#include "qqmlinspectorservice_p.h"
+#include "qqmlprofilerservice_p.h"
+#include "qv4debugservice_p.h"
+#include <QtCore/QPluginLoader>
+#include <QtCore/QCoreApplication>
+#include <QtCore/QDir>
+#include <QtCore/QDebug>
+
+#include <private/qcoreapplication_p.h>
+#include <private/qqmlengine_p.h>
+
+QT_BEGIN_NAMESPACE
+
+extern QQmlDebugConnector *loadQQmlDebugConnector(const QString &key);
+
+struct QQmlDebugConnectorParams {
+ QString pluginKey;
+ QString arguments;
+ QQmlDebugConnector *instance;
+
+ QQmlDebugConnectorParams() : instance(0)
+ {
+ if (qApp) {
+ QCoreApplicationPrivate *appD =
+ static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(qApp));
+ if (appD)
+ arguments = appD->qmljsDebugArgumentsString();
+ }
+ }
+};
+
+Q_GLOBAL_STATIC(QQmlDebugConnectorParams, qmlDebugConnectorParams)
+
+void QQmlDebugConnector::setPluginKey(const QString &key)
+{
+ QQmlDebugConnectorParams *params = qmlDebugConnectorParams();
+ if (params) {
+ if (params->instance)
+ qWarning() << "QML debugger: Cannot set plugin key after loading the plugin.";
+ else
+ params->pluginKey = key;
+ }
+}
+
+QQmlDebugConnector *QQmlDebugConnector::instance()
+{
+ QQmlDebugConnectorParams *params = qmlDebugConnectorParams();
+ if (!params)
+ return 0;
+
+ if (!QQmlEnginePrivate::qml_debugging_enabled) {
+ if (!params->arguments.isEmpty()) {
+ qWarning() << QString::fromLatin1(
+ "QML Debugger: Ignoring \"-qmljsdebugger=%1\". Debugging has not "
+ "been enabled.").arg(params->arguments);
+ params->arguments.clear();
+ }
+ return 0;
+ }
+
+ if (!params->instance) {
+ if (!params->pluginKey.isEmpty()) {
+ if (params->pluginKey != QLatin1String("QQmlDebugServer"))
+ return 0; // We cannot load anything else, yet
+ } else if (params->arguments.isEmpty()) {
+ return 0; // no explicit class name given and no command line arguments
+ }
+ params->instance = loadQQmlDebugConnector(QLatin1String("QQmlDebugServer"));
+ if (params->instance) {
+ QQmlEngineDebugService::instance();
+ QV4DebugService::instance();
+ QQmlProfilerService::instance();
+ QDebugMessageService::instance();
+ QQmlEngineControlService::instance();
+ QQmlInspectorService::instance();
+ }
+ }
+
+ return params->instance;
+}
+
+QT_END_NAMESPACE
diff --git a/src/qml/debugger/qqmldebugconnector_p.h b/src/qml/debugger/qqmldebugconnector_p.h
index 3fd2240a0d..e7b8b98c66 100644
--- a/src/qml/debugger/qqmldebugconnector_p.h
+++ b/src/qml/debugger/qqmldebugconnector_p.h
@@ -57,6 +57,7 @@ class Q_QML_PRIVATE_EXPORT QQmlDebugConnector : public QObject
{
Q_OBJECT
public:
+ static void setPluginKey(const QString &key);
static QQmlDebugConnector *instance();
virtual bool blockingMode() const = 0;
@@ -70,6 +71,7 @@ public:
virtual bool removeService(QQmlDebugService *service) = 0;
virtual void sendMessages(QQmlDebugService *service, const QList<QByteArray> &messages) = 0;
+ virtual bool open(const QVariantHash &configuration = QVariantHash()) = 0;
};
QT_END_NAMESPACE
diff --git a/src/qml/debugger/qqmldebugserver.cpp b/src/qml/debugger/qqmldebugserver.cpp
index 5160aecaee..4d5e3f5605 100644
--- a/src/qml/debugger/qqmldebugserver.cpp
+++ b/src/qml/debugger/qqmldebugserver.cpp
@@ -35,10 +35,6 @@
#include "qqmldebugserverconnection_p.h"
#include "qqmldebugservice_p.h"
#include "qqmldebugservice_p_p.h"
-#include "qqmlenginedebugservice_p.h"
-#include "qv4debugservice_p.h"
-#include "qdebugmessageservice_p.h"
-#include "qqmlprofilerservice_p.h"
#include <private/qqmlengine_p.h>
#include <private/qqmlglobal_p.h>
@@ -103,11 +99,14 @@ public:
bool addService(QQmlDebugService *service);
bool removeService(QQmlDebugService *service);
+ bool open(const QVariantHash &configuration);
+
void receiveMessage(const QByteArray &message);
void sendMessages(QQmlDebugService *service, const QList<QByteArray> &messages);
template<class Action>
- static bool enable(Action action);
+ bool enable(Action action);
+ bool enableFromArguments();
private slots:
void wakeEngine(QQmlEngine *engine);
@@ -119,8 +118,8 @@ private:
friend struct StartTcpServerAction;
friend struct ConnectToLocalAction;
friend class QQmlDebugServerThread;
- friend class QQmlDebugConnector;
friend struct QQmlDebugServerInstanceWrapper;
+ friend QQmlDebugConnector *loadQQmlDebugConnector(const QString &key);
class EngineCondition {
public:
@@ -209,6 +208,42 @@ private:
QString m_fileName;
};
+struct StartTcpServerAction {
+ int portFrom;
+ int portTo;
+ bool block;
+ QString hostAddress;
+
+ StartTcpServerAction(int portFrom, int portTo, bool block, const QString &hostAddress) :
+ portFrom(portFrom), portTo(portTo), block(block), hostAddress(hostAddress) {}
+
+ bool operator()(QQmlDebugServerImpl *d)
+ {
+ if (!d->init(QLatin1String("qmldbg_tcp"), block))
+ return false;
+ d->m_thread->setPortRange(portFrom, portTo == -1 ? portFrom : portTo, block, hostAddress);
+ d->m_thread->start();
+ return true;
+ }
+};
+
+struct ConnectToLocalAction {
+ QString fileName;
+ bool block;
+
+ ConnectToLocalAction(const QString &fileName, bool block) :
+ fileName(fileName), block(block) {}
+
+ bool operator()(QQmlDebugServerImpl *d)
+ {
+ if (!d->init(QLatin1String("qmldbg_local"), block))
+ return false;
+ d->m_thread->setFileName(fileName, block);
+ d->m_thread->start();
+ return true;
+ }
+};
+
void QQmlDebugServerImpl::advertisePlugins()
{
if (!m_gotHello)
@@ -357,15 +392,11 @@ bool QQmlDebugServerImpl::blockingMode() const
return m_blockingMode;
}
-QQmlDebugConnector *QQmlDebugConnector::instance()
+QQmlDebugConnector *loadQQmlDebugConnector(const QString &key)
{
- QQmlDebugServerInstanceWrapper *wrapper = debugServerInstance();
- if (wrapper && wrapper->m_instance.m_thread) {
- QQmlDebugServerImpl *ret = &(wrapper->m_instance);
- QMutexLocker locker(&ret->m_helloMutex);
- if (ret->m_blockingMode && !ret->m_gotHello)
- ret->m_helloCondition.wait(&ret->m_helloMutex);
- return ret;
+ if (key == QLatin1String("QQmlDebugServer")) {
+ QQmlDebugServerInstanceWrapper *wrapper = debugServerInstance();
+ return wrapper ? &(wrapper->m_instance) : 0;
} else {
return 0;
}
@@ -380,8 +411,6 @@ static void cleanupOnShutdown()
bool QQmlDebugServerImpl::init(const QString &pluginName, bool block)
{
- if (!QQmlEnginePrivate::qml_debugging_enabled)
- return false;
if (m_thread)
return false;
static bool postRoutineAdded = false;
@@ -414,9 +443,30 @@ QQmlDebugServerImpl::QQmlDebugServerImpl() :
qRegisterMetaType<QList<QByteArray> >("QList<QByteArray>");
// used in changeServiceState
qRegisterMetaType<QQmlDebugService::State>("QQmlDebugService::State");
+}
+bool QQmlDebugServerImpl::open(const QVariantHash &configuration = QVariantHash())
+{
+ if (configuration.isEmpty()) {
+ return enableFromArguments();
+ } if (configuration.contains(QLatin1String("portFrom"))) {
+ return enable(StartTcpServerAction(
+ configuration[QLatin1String("portFrom")].toInt(),
+ configuration[QLatin1String("portTo")].toInt(),
+ configuration[QLatin1String("block")].toBool(),
+ configuration[QLatin1String("hostAddress")].toString()));
+ } else if (configuration.contains(QLatin1String("fileName"))) {
+ return enable(ConnectToLocalAction(configuration[QLatin1String("fileName")].toString(),
+ configuration[QLatin1String("block")].toBool()));
+ }
+
+ return false;
+}
+
+bool QQmlDebugServerImpl::enableFromArguments()
+{
if (qApp == 0)
- return;
+ return false;
QCoreApplicationPrivate *appD = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(qApp));
#ifndef QT_NO_QML_DEBUGGER
// ### remove port definition when protocol is changed
@@ -429,15 +479,6 @@ QQmlDebugServerImpl::QQmlDebugServerImpl() :
// format: qmljsdebugger=port:<port_from>[,port_to],host:<ip address>][,block]
if (!appD->qmljsDebugArgumentsString().isEmpty()) {
- if (!QQmlEnginePrivate::qml_debugging_enabled) {
- qWarning() << QString(QLatin1String(
- "QML Debugger: Ignoring \"-qmljsdebugger=%1\". "
- "Debugging has not been enabled.")).arg(
- appD->qmljsDebugArgumentsString());
- return;
- }
-
- QString pluginName;
QStringList lstjsDebugArguments = appD->qmljsDebugArgumentsString()
.split(QLatin1Char(','));
QStringList::const_iterator argsItEnd = lstjsDebugArguments.cend();
@@ -445,7 +486,6 @@ QQmlDebugServerImpl::QQmlDebugServerImpl() :
for (; argsIt != argsItEnd; ++argsIt) {
const QString strArgument = *argsIt;
if (strArgument.startsWith(QLatin1String("port:"))) {
- pluginName = QLatin1String("qmldbg_tcp");
portFrom = strArgument.mid(5).toInt(&ok);
portTo = portFrom;
QStringList::const_iterator argsNext = argsIt + 1;
@@ -461,7 +501,6 @@ QQmlDebugServerImpl::QQmlDebugServerImpl() :
} else if (strArgument == QLatin1String("block")) {
block = true;
} else if (strArgument.startsWith(QLatin1String("file:"))) {
- pluginName = QLatin1String("qmldbg_local");
fileName = strArgument.mid(5);
ok = !fileName.isEmpty();
} else {
@@ -472,13 +511,10 @@ QQmlDebugServerImpl::QQmlDebugServerImpl() :
}
if (ok) {
- if (init(pluginName, block)) {
- if (!fileName.isEmpty())
- m_thread->setFileName(fileName, block);
- else
- m_thread->setPortRange(portFrom, portTo, block, hostAddress);
- m_thread->start();
- }
+ if (!fileName.isEmpty())
+ return enable(ConnectToLocalAction(fileName, block));
+ else
+ return enable(StartTcpServerAction(portFrom, portTo, block, hostAddress));
} else {
qWarning() << QString(QLatin1String(
"QML Debugger: Ignoring \"-qmljsdebugger=%1\". "
@@ -494,6 +530,7 @@ QQmlDebugServerImpl::QQmlDebugServerImpl() :
appD->qmljsDebugArgumentsString());
}
#endif
+ return false;
}
void QQmlDebugServerImpl::receiveMessage(const QByteArray &message)
@@ -688,7 +725,7 @@ void QQmlDebugServerImpl::removeEngine(QQmlEngine *engine)
bool QQmlDebugServerImpl::addService(QQmlDebugService *service)
{
// to be executed outside of debugger thread
- Q_ASSERT(QThread::currentThread() != thread());
+ Q_ASSERT(!m_thread || QThread::currentThread() != thread());
connect(service, SIGNAL(attachedToEngine(QQmlEngine*)),
this, SLOT(wakeEngine(QQmlEngine*)), Qt::QueuedConnection);
@@ -711,7 +748,7 @@ bool QQmlDebugServerImpl::addService(QQmlDebugService *service)
bool QQmlDebugServerImpl::removeService(QQmlDebugService *service)
{
// to be executed outside of debugger thread
- Q_ASSERT(QThread::currentThread() != thread());
+ Q_ASSERT(!m_thread || QThread::currentThread() != thread());
QWriteLocker lock(&m_pluginsLock);
QQmlDebugService::State newState = QQmlDebugService::NotConnected;
@@ -745,58 +782,21 @@ void QQmlDebugServerImpl::sendMessages(QQmlDebugService *service, const QList<QB
Q_ARG(QList<QByteArray>, prefixedMessages));
}
-struct StartTcpServerAction {
- int portFrom;
- int portTo;
- bool block;
- QString hostAddress;
-
- StartTcpServerAction(int portFrom, int portTo, bool block, const QString &hostAddress) :
- portFrom(portFrom), portTo(portTo), block(block), hostAddress(hostAddress) {}
-
- bool operator()(QQmlDebugServerImpl *d)
- {
- if (!d->init(QLatin1String("qmldbg_tcp"), block))
- return false;
- d->m_thread->setPortRange(portFrom, portTo == -1 ? portFrom : portTo, block, hostAddress);
- d->m_thread->start();
- return true;
- }
-};
-
-struct ConnectToLocalAction {
- QString fileName;
- bool block;
-
- ConnectToLocalAction(const QString &fileName, bool block) :
- fileName(fileName), block(block) {}
-
- bool operator()(QQmlDebugServerImpl *d)
- {
- if (!d->init(QLatin1String("qmldbg_local"), block))
- return false;
- d->m_thread->setFileName(fileName, block);
- d->m_thread->start();
- return true;
- }
-};
-
template<class Action>
bool QQmlDebugServerImpl::enable(Action action)
{
#ifndef QT_NO_QML_DEBUGGER
- QQmlDebugServerInstanceWrapper *wrapper = debugServerInstance();
- if (!wrapper)
- return false;
- QQmlDebugServerImpl *d = &wrapper->m_instance;
- if (d->m_thread)
+ if (m_thread)
return false;
- if (!action(d))
+ if (!action(this))
return false;
- while (!d->m_connection) {
- if (!d->m_thread)
+ while (!m_connection) {
+ if (!m_thread)
return false;
}
+ QMutexLocker locker(&m_helloMutex);
+ if (m_blockingMode && !m_gotHello)
+ m_helloCondition.wait(&m_helloMutex);
return true;
#else
Q_UNUSED(action);
@@ -804,58 +804,6 @@ bool QQmlDebugServerImpl::enable(Action action)
#endif
}
-/*!
- * \enum QQmlDebuggingEnabler::StartMode
- *
- * Defines the debug server's start behavior. You can interrupt QML engines starting while a debug
- * client is connecting, in order to set breakpoints in or profile startup code.
- *
- * \value DoNotWaitForClient Run any QML engines as usual while the debug services are connecting.
- * \value WaitForClient If a QML engine starts while the debug services are connecting,
- * interrupt it until they are done.
- */
-
-/*!
- * Enables debugging for QML engines created after calling this function. The debug server will
- * listen on \a port at \a hostName and block the QML engine until it receives a connection if
- * \a mode is \c WaitForClient. If \a mode is not specified it won't block and if \a hostName is not
- * specified it will listen on all available interfaces. You can only start one debug server at a
- * time. A debug server may have already been started if the -qmljsdebugger= command line argument
- * was given. This method returns \c true if a new debug server was successfully started, or
- * \c false otherwise.
- */
-bool QQmlDebuggingEnabler::startTcpDebugServer(int port, StartMode mode, const QString &hostName)
-{
-#ifndef QQML_NO_DEBUG_PROTOCOL
- return QQmlDebugServerImpl::enable(StartTcpServerAction(port, port, mode == WaitForClient,
- hostName));
-#else
- Q_UNUSED(port);
- Q_UNUSED(block);
- Q_UNUSED(hostName);
- return false;
-#endif
-}
-
-/*!
- * Enables debugging for QML engines created after calling this function. The debug server will
- * connect to a debugger waiting on a local socket at the given \a socketFileName and block the QML
- * engine until the connection is established if \a mode is \c WaitForClient. If \a mode is not
- * specified it will not block. You can only start one debug server at a time. A debug server may
- * have already been started if the -qmljsdebugger= command line argument was given. This method
- * returns \c true if a new debug server was successfully started, or \c false otherwise.
- */
-bool QQmlDebuggingEnabler::connectToLocalDebugger(const QString &socketFileName, StartMode mode)
-{
-#ifndef QQML_NO_DEBUG_PROTOCOL
- return QQmlDebugServerImpl::enable(ConnectToLocalAction(socketFileName, mode == WaitForClient));
-#else
- Q_UNUSED(fileName);
- Q_UNUSED(block);
- return false;
-#endif
-}
-
void QQmlDebugServerImpl::wakeEngine(QQmlEngine *engine)
{
// to be executed in debugger thread
diff --git a/src/qml/debugger/qqmlprofilerservice.cpp b/src/qml/debugger/qqmlprofilerservice.cpp
index 4a4f70b894..4062f2f33c 100644
--- a/src/qml/debugger/qqmlprofilerservice.cpp
+++ b/src/qml/debugger/qqmlprofilerservice.cpp
@@ -106,19 +106,22 @@ QQmlProfilerService *QQmlProfilerService::instance()
void QQmlProfilerService::engineAboutToBeAdded(QQmlEngine *engine)
{
- Q_ASSERT_X(QThread::currentThread() != thread(), Q_FUNC_INFO, "QML profilers have to be added from the engine thread");
+ Q_ASSERT_X(QThread::currentThread() == engine->thread(), Q_FUNC_INFO,
+ "QML profilers have to be added from the engine thread");
QMutexLocker lock(configMutex());
QQmlProfilerAdapter *qmlAdapter = new QQmlProfilerAdapter(this, QQmlEnginePrivate::get(engine));
QV4ProfilerAdapter *v4Adapter = new QV4ProfilerAdapter(this, QV8Engine::getV4(engine->handle()));
addEngineProfiler(qmlAdapter, engine);
addEngineProfiler(v4Adapter, engine);
+
QQmlConfigurableDebugService::engineAboutToBeAdded(engine);
}
void QQmlProfilerService::engineAdded(QQmlEngine *engine)
{
- Q_ASSERT_X(QThread::currentThread() != thread(), Q_FUNC_INFO, "QML profilers have to be added from the engine thread");
+ Q_ASSERT_X(QThread::currentThread() == engine->thread(), Q_FUNC_INFO,
+ "QML profilers have to be added from the engine thread");
QMutexLocker lock(configMutex());
foreach (QQmlAbstractProfilerAdapter *profiler, m_engineProfilers.values(engine))
@@ -127,7 +130,8 @@ void QQmlProfilerService::engineAdded(QQmlEngine *engine)
void QQmlProfilerService::engineAboutToBeRemoved(QQmlEngine *engine)
{
- Q_ASSERT_X(QThread::currentThread() != thread(), Q_FUNC_INFO, "QML profilers have to be removed from the engine thread");
+ Q_ASSERT_X(QThread::currentThread() == engine->thread(), Q_FUNC_INFO,
+ "QML profilers have to be removed from the engine thread");
QMutexLocker lock(configMutex());
bool isRunning = false;
@@ -146,7 +150,8 @@ void QQmlProfilerService::engineAboutToBeRemoved(QQmlEngine *engine)
void QQmlProfilerService::engineRemoved(QQmlEngine *engine)
{
- Q_ASSERT_X(QThread::currentThread() != thread(), Q_FUNC_INFO, "QML profilers have to be removed from the engine thread");
+ Q_ASSERT_X(QThread::currentThread() == engine->thread(), Q_FUNC_INFO,
+ "QML profilers have to be removed from the engine thread");
QMutexLocker lock(configMutex());
foreach (QQmlAbstractProfilerAdapter *profiler, m_engineProfilers.values(engine)) {
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index 34015c17da..1ed102f0c9 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -42,7 +42,6 @@
#include "qqmlexpression.h"
#include "qqmlcomponent.h"
#include "qqmlvme_p.h"
-#include <private/qqmlenginedebugservice_p.h>
#include "qqmlstringconverters_p.h"
#include "qqmlxmlhttprequest_p.h"
#include "qqmlscriptstring.h"
@@ -55,10 +54,6 @@
#include "qqmltypenamecache_p.h"
#include "qqmlnotifier_p.h"
#include <private/qqmldebugconnector_p.h>
-#include <private/qqmlprofilerservice_p.h>
-#include <private/qv4debugservice_p.h>
-#include <private/qdebugmessageservice_p.h>
-#include <private/qqmlenginecontrolservice_p.h>
#include "qqmlincubator.h"
#include "qqmlabstracturlinterceptor.h"
#include <private/qqmlboundsignal_p.h>
@@ -863,11 +858,7 @@ void QQmlEnginePrivate::init()
if (QCoreApplication::instance()->thread() == q->thread() && QQmlDebugConnector::instance()) {
isDebugging = true;
- QQmlEngineDebugService::instance();
- QV4DebugService::instance();
- QQmlProfilerService::instance();
- QDebugMessageService::instance();
- QQmlEngineControlService::instance();
+ QQmlDebugConnector::instance()->open();
QQmlDebugConnector::instance()->addEngine(q);
}
}
@@ -1487,19 +1478,6 @@ Q_QML_EXPORT QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *o
#endif // QT_DEPRECATED_SINCE(5, 1)
-QQmlDebuggingEnabler::QQmlDebuggingEnabler(bool printWarning)
-{
-#ifndef QQML_NO_DEBUG_PROTOCOL
- if (!QQmlEnginePrivate::qml_debugging_enabled
- && printWarning) {
- qDebug("QML debugging is enabled. Only use this in a safe environment.");
- }
- QQmlEnginePrivate::qml_debugging_enabled = true;
-#else
- Q_UNUSED(printWarning);
-#endif
-}
-
class QQmlDataExtended {
public:
QQmlDataExtended();