QDeclarativeDebugServer: Crash Fix
authorAurindam Jana <aurindam.jana@nokia.com>
Thu, 17 Nov 2011 11:19:45 +0000 (12:19 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 17 Nov 2011 15:53:24 +0000 (16:53 +0100)
Instantiate QPluginLoader on heap.

Change-Id: I53a7cb669379d374e8b6f83fe998c0bb17fbce33
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>

src/declarative/debugger/qdeclarativedebugserver.cpp

index a4f5bd2..5c86c45 100644 (file)
@@ -98,7 +98,8 @@ public:
 private:
     // private slot
     void _q_deliverMessage(const QString &serviceName, const QByteArray &message);
-    static QDeclarativeDebugServerConnection *loadConnectionPlugin(const QString &pluginName);
+    static QDeclarativeDebugServerConnection *loadConnectionPlugin(QPluginLoader *loader, const QString &pluginName);
+
 };
 
 QDeclarativeDebugServerPrivate::QDeclarativeDebugServerPrivate() :
@@ -122,7 +123,7 @@ void QDeclarativeDebugServerPrivate::advertisePlugins()
 }
 
 QDeclarativeDebugServerConnection *QDeclarativeDebugServerPrivate::loadConnectionPlugin(
-        const QString &pluginName)
+        QPluginLoader *loader, const QString &pluginName)
 {
 #ifndef QT_NO_LIBRARY
     QStringList pluginCandidates;
@@ -142,14 +143,14 @@ QDeclarativeDebugServerConnection *QDeclarativeDebugServerPrivate::loadConnectio
         if (qmlDebugVerbose())
             qDebug() << "QDeclarativeDebugServer: Trying to load plugin " << pluginPath << "...";
 
-        QPluginLoader loader(pluginPath);
-        if (!loader.load()) {
+        loader->setFileName(pluginPath);
+        if (!loader->load()) {
             if (qmlDebugVerbose())
-                qDebug() << "QDeclarativeDebugServer: Error while loading: " << loader.errorString();
+                qDebug() << "QDeclarativeDebugServer: Error while loading: " << loader->errorString();
             continue;
         }
         QDeclarativeDebugServerConnection *connection = 0;
-        if (QObject *instance = loader.instance())
+        if (QObject *instance = loader->instance())
             connection = qobject_cast<QDeclarativeDebugServerConnection*>(instance);
 
         if (connection) {
@@ -162,7 +163,7 @@ QDeclarativeDebugServerConnection *QDeclarativeDebugServerPrivate::loadConnectio
         if (qmlDebugVerbose())
             qDebug() << "QDeclarativeDebugServer: Plugin does not implement interface QDeclarativeDebugServerConnection.";
 
-        loader.unload();
+        loader->unload();
     }
 #endif
     return 0;
@@ -215,9 +216,9 @@ QDeclarativeDebugServer *QDeclarativeDebugServer::instance()
 
             if (ok) {
                 server = new QDeclarativeDebugServer();
-
+                QPluginLoader *loader = new QPluginLoader(server);
                 QDeclarativeDebugServerConnection *connection
-                        = QDeclarativeDebugServerPrivate::loadConnectionPlugin(pluginName);
+                        = QDeclarativeDebugServerPrivate::loadConnectionPlugin(loader, pluginName);
                 if (connection) {
                     server->d_func()->connection = connection;