diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2016-03-17 16:17:15 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2016-03-26 12:22:24 +0000 |
commit | 19d16b33ad2bf7312e2470f31f43fa1acf92f088 (patch) | |
tree | 53fa6abe329bf37e8a2f4f7a6eb872aaced74456 /src/qml/debugger/qqmldebug.cpp | |
parent | 5ce1b892a14a9940e4c8abbbed69bc011394c617 (diff) |
Allow custom debug connectors
Expose a generic method for loading connector plugins in
QQmlDebuggingEnabler and don't insist on the two known ones when
actually loading them. This allows third-party connector plugins
to be loaded, for example to pass QML trace events to a generic
tracing library.
Change-Id: I4f66dfabdbd0c3aff3676f7e2591e0a6c42f8f7f
Reviewed-by: hjk <hjk@theqtcompany.com>
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/debugger/qqmldebug.cpp')
-rw-r--r-- | src/qml/debugger/qqmldebug.cpp | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/src/qml/debugger/qqmldebug.cpp b/src/qml/debugger/qqmldebug.cpp index 64a951d53b..9276bd0544 100644 --- a/src/qml/debugger/qqmldebug.cpp +++ b/src/qml/debugger/qqmldebug.cpp @@ -134,22 +134,11 @@ void QQmlDebuggingEnabler::setServices(const QStringList &services) */ 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(mode); - Q_UNUSED(hostName); -#endif - return false; + QVariantHash configuration; + configuration[QLatin1String("portFrom")] = configuration[QLatin1String("portTo")] = port; + configuration[QLatin1String("block")] = (mode == WaitForClient); + configuration[QLatin1String("hostAddress")] = hostName; + return startDebugConnector(QLatin1String("QQmlDebugServer"), configuration); } /*! @@ -164,18 +153,33 @@ bool QQmlDebuggingEnabler::startTcpDebugServer(int port, StartMode mode, const Q */ bool QQmlDebuggingEnabler::connectToLocalDebugger(const QString &socketFileName, StartMode mode) { + QVariantHash configuration; + configuration[QLatin1String("fileName")] = socketFileName; + configuration[QLatin1String("block")] = (mode == WaitForClient); + return startDebugConnector(QLatin1String("QQmlDebugServer"), configuration); +} + +/*! + * \since 5.7 + * + * Enables debugging for QML engines created after calling this function. A debug connector plugin + * specified by \a pluginName will be loaded and started using the given \a configuration. Supported + * configuration entries and their semantics depend on the plugin being loaded. You can only start + * one debug connector at a time. A debug connector may have already been started if the + * -qmljsdebugger= command line argument was given. This method returns \c true if a new debug + * connector was successfully started, or \c false otherwise. + */ +bool QQmlDebuggingEnabler::startDebugConnector(const QString &pluginName, + const QVariantHash &configuration) +{ #ifndef QQML_NO_DEBUG_PROTOCOL - QQmlDebugConnector::setPluginKey(QLatin1String("QQmlDebugServer")); + QQmlDebugConnector::setPluginKey(pluginName); QQmlDebugConnector *connector = QQmlDebugConnector::instance(); - if (connector) { - QVariantHash configuration; - configuration[QLatin1String("fileName")] = socketFileName; - configuration[QLatin1String("block")] = (mode == WaitForClient); + if (connector) return connector->open(configuration); - } #else - Q_UNUSED(fileName); - Q_UNUSED(mode); + Q_UNUSED(pluginName); + Q_UNUSED(configuration); #endif return false; } |