aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-07-15 15:19:50 +0200
committerUlf Hermann <ulf.hermann@theqtcompany.com>2015-08-04 13:34:52 +0000
commit2f190e21c82c7b20f6cf1b9e5671316cd831f684 (patch)
tree14c7fbd2226842894518b0c964f7e6ce97796ea1
parenta010f3a8f92a9a364e9d17d12b06074fde6f8a17 (diff)
Use QQmlDebugPluginManager for loading connection plugins
Also remove all the hacks that deal with static builds, QT_NO_LIBRARY and friends. QQmlDebugPluginManager handles those cases. Change-Id: I62f13b787292108fa25d09fabc775332394989be Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
-rw-r--r--src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp5
-rw-r--r--src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.h11
-rw-r--r--src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.json3
-rw-r--r--src/plugins/qmltooling/qmldbg_local/qmldbg_local.pro5
-rw-r--r--src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp77
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro5
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp5
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h11
-rw-r--r--src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.json3
-rw-r--r--src/plugins/qmltooling/shared/qqmldebugserverconnection.h10
10 files changed, 58 insertions, 77 deletions
diff --git a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp
index cf4512cc6e..993bafcf9f 100644
--- a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp
+++ b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.cpp
@@ -142,4 +142,9 @@ void QLocalClientConnection::connectionEstablished()
d->debugServer->setDevice(d->socket);
}
+QQmlDebugServerConnection *QLocalClientConnectionFactory::create(const QString &key)
+{
+ return (key == QLatin1String("QLocalClientConnection") ? new QLocalClientConnection : 0);
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.h b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.h
index 4d20b8db2f..119f29921b 100644
--- a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.h
+++ b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.h
@@ -44,8 +44,6 @@ class QLocalClientConnection : public QObject, public QQmlDebugServerConnection
Q_OBJECT
Q_DECLARE_PRIVATE(QLocalClientConnection)
Q_DISABLE_COPY(QLocalClientConnection)
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlDebugServerConnection")
- Q_INTERFACES(QQmlDebugServerConnection)
public:
QLocalClientConnection();
@@ -70,6 +68,15 @@ private:
QLocalClientConnectionPrivate *d_ptr;
};
+class QLocalClientConnectionFactory : public QQmlDebugServerConnectionFactory
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlDebugServerConnectionFactory_iid FILE "qlocalclientconnection.json")
+ Q_INTERFACES(QQmlDebugServerConnectionFactory)
+public:
+ QQmlDebugServerConnection *create(const QString &key);
+};
+
QT_END_NAMESPACE
#endif // QLOCALCLIENTCONNECTION_H
diff --git a/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.json b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.json
new file mode 100644
index 0000000000..5f8fd49296
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_local/qlocalclientconnection.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "QLocalClientConnection" ]
+}
diff --git a/src/plugins/qmltooling/qmldbg_local/qmldbg_local.pro b/src/plugins/qmltooling/qmldbg_local/qmldbg_local.pro
index 4fa05234e6..f190368441 100644
--- a/src/plugins/qmltooling/qmldbg_local/qmldbg_local.pro
+++ b/src/plugins/qmltooling/qmldbg_local/qmldbg_local.pro
@@ -2,7 +2,7 @@ TARGET = qmldbg_local
QT = qml-private
PLUGIN_TYPE = qmltooling
-PLUGIN_CLASS_NAME = QLocalClientConnection
+PLUGIN_CLASS_NAME = QLocalClientConnectionFactory
load(qt_plugin)
SOURCES += \
@@ -15,3 +15,6 @@ HEADERS += \
INCLUDEPATH += $$PWD \
$$PWD/../shared
+
+OTHER_FILES += \
+ $$PWD/qlocalclientconnection.json
diff --git a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
index 4a4af77064..2d79777c2c 100644
--- a/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
+++ b/src/plugins/qmltooling/qmldbg_server/qqmldebugserver.cpp
@@ -39,6 +39,7 @@
#include <private/qqmldebugservice_p.h>
#include <private/qqmlengine_p.h>
#include <private/qqmlglobal_p.h>
+#include <private/qqmldebugpluginmanager_p.h>
#include <QtCore/QAtomicInt>
#include <QtCore/QDir>
@@ -49,10 +50,6 @@
#include <private/qobject_p.h>
#include <private/qcoreapplication_p.h>
-#if defined(QT_STATIC) && !defined(QT_NO_LIBRARY)
-#include "../../plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h"
-#endif
-
QT_BEGIN_NAMESPACE
/*
@@ -77,12 +74,11 @@ QT_BEGIN_NAMESPACE
Everything send with a header different to "QDeclarativeDebugServer" is sent to the appropriate plugin.
*/
-const int protocolVersion = 1;
+Q_QML_DEBUG_PLUGIN_LOADER(QQmlDebugServerConnection)
+Q_QML_IMPORT_DEBUG_PLUGIN(QTcpServerConnectionFactory)
+Q_QML_IMPORT_DEBUG_PLUGIN(QLocalClientConnectionFactory)
-// print detailed information about loading of plugins
-#ifndef QT_NO_LIBRARY
-DEFINE_BOOL_CONFIG_OPTION(qmlDebugVerbose, QML_DEBUGGER_VERBOSE)
-#endif
+const int protocolVersion = 1;
class QQmlDebugServerThread;
class QQmlDebugServerImpl : public QQmlDebugServer
@@ -143,7 +139,6 @@ private:
bool canSendMessage(const QString &name);
void doSendMessage(const QString &name, const QByteArray &message);
- QQmlDebugServerConnection *loadConnectionPlugin(const QString &pluginName);
QQmlDebugServerConnection *m_connection;
QHash<QString, QQmlDebugService *> m_plugins;
@@ -157,9 +152,6 @@ private:
QWaitCondition m_helloCondition;
QQmlDebugServerThread *m_thread;
QPacketProtocol *m_protocol;
-#ifndef QT_NO_LIBRARY
- QPluginLoader m_loader;
-#endif
QAtomicInt m_changeServiceStateCalls;
};
@@ -209,7 +201,7 @@ struct StartTcpServerAction {
bool operator()(QQmlDebugServerImpl *d)
{
- if (!d->init(QLatin1String("qmldbg_tcp"), block))
+ if (!d->init(QLatin1String("QTcpServerConnection"), block))
return false;
d->m_thread->setPortRange(portFrom, portTo == -1 ? portFrom : portTo, block, hostAddress);
return true;
@@ -225,7 +217,7 @@ struct ConnectToLocalAction {
bool operator()(QQmlDebugServerImpl *d)
{
- if (!d->init(QLatin1String("qmldbg_local"), block))
+ if (!d->init(QLatin1String("QLocalClientConnection"), block))
return false;
d->m_thread->setFileName(fileName, block);
return true;
@@ -263,63 +255,10 @@ void QQmlDebugServerImpl::cleanup()
}
}
-QQmlDebugServerConnection *QQmlDebugServerImpl::loadConnectionPlugin(const QString &pluginName)
-{
-#ifndef QT_NO_LIBRARY
- QStringList pluginCandidates;
- const QStringList paths = QCoreApplication::libraryPaths();
- foreach (const QString &libPath, paths) {
- const QDir dir(libPath + QLatin1String("/qmltooling"));
- if (dir.exists()) {
- QStringList plugins(dir.entryList(QDir::Files));
- foreach (const QString &pluginPath, plugins) {
- if (QFileInfo(pluginPath).fileName().contains(pluginName))
- pluginCandidates << dir.absoluteFilePath(pluginPath);
- }
- }
- }
-
- QQmlDebugServerConnection *loadedConnection = 0;
- foreach (const QString &pluginPath, pluginCandidates) {
- if (qmlDebugVerbose())
- qDebug() << "QML Debugger: Trying to load plugin " << pluginPath << "...";
-
- m_loader.setFileName(pluginPath);
- if (!m_loader.load()) {
- if (qmlDebugVerbose())
- qDebug() << "QML Debugger: Error while loading: " << m_loader.errorString();
- continue;
- }
- if (QObject *instance = m_loader.instance())
- loadedConnection = qobject_cast<QQmlDebugServerConnection*>(instance);
-
- if (loadedConnection) {
- if (qmlDebugVerbose())
- qDebug() << "QML Debugger: Plugin successfully loaded.";
-
- return loadedConnection;
- }
-
- if (qmlDebugVerbose())
- qDebug() << "QML Debugger: Plugin does not implement interface QQmlDebugServerConnection.";
-
- m_loader.unload();
- }
-#else
- Q_UNUSED(pluginName);
-#endif
- return 0;
-}
-
void QQmlDebugServerThread::run()
{
Q_ASSERT_X(m_server != 0, Q_FUNC_INFO, "There should always be a debug server available here.");
-#if defined(QT_STATIC) && !defined(QT_NO_LIBRARY)
- QQmlDebugServerConnection *connection
- = new QTcpServerConnection;
-#else
- QQmlDebugServerConnection *connection = m_server->loadConnectionPlugin(m_pluginName);
-#endif
+ QQmlDebugServerConnection *connection = loadQQmlDebugServerConnection(m_pluginName);
if (connection) {
connection->setServer(m_server);
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro b/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro
index 15ba7c730a..b6d25e0e9e 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro
+++ b/src/plugins/qmltooling/qmldbg_tcp/qmldbg_tcp.pro
@@ -2,7 +2,7 @@ TARGET = qmldbg_tcp
QT = qml-private network
PLUGIN_TYPE = qmltooling
-PLUGIN_CLASS_NAME = QTcpServerConnection
+PLUGIN_CLASS_NAME = QTcpServerConnectionFactory
load(qt_plugin)
SOURCES += \
@@ -15,3 +15,6 @@ HEADERS += \
INCLUDEPATH += $$PWD \
$$PWD/../shared
+
+OTHER_FILES += \
+ $$PWD/qtcpserverconnection.json
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
index 7734e5ed0d..689c98f2b9 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.cpp
@@ -189,4 +189,9 @@ void QTcpServerConnection::newConnection()
d->debugServer->setDevice(d->socket);
}
+QQmlDebugServerConnection *QTcpServerConnectionFactory::create(const QString &key)
+{
+ return (key == QLatin1String("QTcpServerConnection") ? new QTcpServerConnection : 0);
+}
+
QT_END_NAMESPACE
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
index 8b2aed0b55..f405e83aac 100644
--- a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.h
@@ -44,8 +44,6 @@ class QTcpServerConnection : public QObject, public QQmlDebugServerConnection
Q_OBJECT
Q_DECLARE_PRIVATE(QTcpServerConnection)
Q_DISABLE_COPY(QTcpServerConnection)
- Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlDebugServerConnection")
- Q_INTERFACES(QQmlDebugServerConnection)
public:
QTcpServerConnection();
@@ -70,6 +68,15 @@ private:
QTcpServerConnectionPrivate *d_ptr;
};
+class QTcpServerConnectionFactory : public QQmlDebugServerConnectionFactory
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID QQmlDebugServerConnectionFactory_iid FILE "qtcpserverconnection.json")
+ Q_INTERFACES(QQmlDebugServerConnectionFactory)
+public:
+ QQmlDebugServerConnection *create(const QString &key);
+};
+
QT_END_NAMESPACE
#endif // QTCPSERVERCONNECTION_H
diff --git a/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.json b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.json
new file mode 100644
index 0000000000..201a1b3fcb
--- /dev/null
+++ b/src/plugins/qmltooling/qmldbg_tcp/qtcpserverconnection.json
@@ -0,0 +1,3 @@
+{
+ "Keys": [ "QTcpServerConnection" ]
+}
diff --git a/src/plugins/qmltooling/shared/qqmldebugserverconnection.h b/src/plugins/qmltooling/shared/qqmldebugserverconnection.h
index 04e4c056ac..03cbe19321 100644
--- a/src/plugins/qmltooling/shared/qqmldebugserverconnection.h
+++ b/src/plugins/qmltooling/shared/qqmldebugserverconnection.h
@@ -66,9 +66,15 @@ public:
virtual void flush() = 0;
};
-#define QQmlDebugServerConnection_iid "org.qt-project.Qt.QQmlDebugServerConnection"
+class QQmlDebugServerConnectionFactory : public QObject
+{
+ Q_OBJECT
+public:
+ virtual QQmlDebugServerConnection *create(const QString &key) = 0;
+};
-Q_DECLARE_INTERFACE(QQmlDebugServerConnection, QQmlDebugServerConnection_iid)
+#define QQmlDebugServerConnectionFactory_iid "org.qt-project.Qt.QQmlDebugServerConnectionFactory"
+Q_DECLARE_INTERFACE(QQmlDebugServerConnectionFactory, QQmlDebugServerConnectionFactory_iid)
QT_END_NAMESPACE