From: Aurindam Jana Date: Thu, 17 Nov 2011 11:19:45 +0000 (+0100) Subject: QDeclarativeDebugServer: Crash Fix X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=1bc5117533b09548f7b669a47ae4657b2d22f561;p=konrad%2Fqtdeclarative.git QDeclarativeDebugServer: Crash Fix Instantiate QPluginLoader on heap. Change-Id: I53a7cb669379d374e8b6f83fe998c0bb17fbce33 Reviewed-by: Kai Koehne --- diff --git a/src/declarative/debugger/qdeclarativedebugserver.cpp b/src/declarative/debugger/qdeclarativedebugserver.cpp index a4f5bd2..5c86c45 100644 --- a/src/declarative/debugger/qdeclarativedebugserver.cpp +++ b/src/declarative/debugger/qdeclarativedebugserver.cpp @@ -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(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;