From 7c5d13df7ec850196a6f9bb739deafbee32c77ee Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 16 Nov 2011 12:31:51 +0100 Subject: qmlplugindump: Fix dumping empty names for generated QMetaObjects. Task-number: QTCREATORBUG-6543 Reviewed-by: Roberto Raggi --- tools/qmlplugindump/main.cpp | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index e9547af..4f523b9 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -147,6 +147,31 @@ QByteArray convertToId(const QByteArray &cppName) return cppToId.value(cppName, cppName); } +QByteArray convertToId(const QMetaObject *mo) +{ + QByteArray className(mo->className()); + if (!className.isEmpty()) + return convertToId(className); + + // likely a metaobject generated for an extended qml object + if (mo->superClass()) { + className = convertToId(mo->superClass()); + className.append("_extended"); + return className; + } + + static QHash generatedNames; + className = generatedNames.value(mo); + if (!className.isEmpty()) + return className; + + qWarning() << "Found a QMetaObject without a className, generating a random name"; + className = QByteArray("error-unknown-name-"); + className.append(QByteArray::number(generatedNames.size())); + generatedNames.insert(mo, className); + return className; +} + QSet collectReachableMetaObjects(const QList &skip = QList()) { QSet metas; @@ -241,7 +266,7 @@ public: { qml->writeStartObject("Component"); - QByteArray id = convertToId(meta->className()); + QByteArray id = convertToId(meta); qml->writeScriptBinding(QLatin1String("name"), enquote(id)); for (int index = meta->classInfoCount() - 1 ; index >= 0 ; --index) { @@ -253,7 +278,7 @@ public: } if (meta->superClass()) - qml->writeScriptBinding(QLatin1String("prototype"), enquote(convertToId(meta->superClass()->className()))); + qml->writeScriptBinding(QLatin1String("prototype"), enquote(convertToId(meta->superClass()))); QSet qmlTypes = qmlTypesByCppName.value(meta->className()); if (!qmlTypes.isEmpty()) { @@ -284,7 +309,7 @@ public: if (const QMetaObject *attachedType = (*qmlTypes.begin())->attachedPropertiesType()) { qml->writeScriptBinding(QLatin1String("attachedType"), enquote( - convertToId(attachedType->className()))); + convertToId(attachedType))); } } @@ -624,7 +649,7 @@ int main(int argc, char *argv[]) // put the metaobjects into a map so they are always dumped in the same order QMap nameToMeta; foreach (const QMetaObject *meta, metas) - nameToMeta.insert(convertToId(meta->className()), meta); + nameToMeta.insert(convertToId(meta), meta); Dumper dumper(&qml); if (relocatable) -- cgit v0.12 From 8c898d681d12f3c67e396e7e2f2aa5522288aa63 Mon Sep 17 00:00:00 2001 From: Aurindam Jana Date: Thu, 17 Nov 2011 15:42:48 +0100 Subject: DeclarativeDebugServer: Instantiate QPluginLoader on heap The pluginloader is instantiated on heap with server as its parent so that the connection plugin instance remains loaded in memory. This prevents the plugin loader in QDeclarativeInspectorService to accidentally un-load the plugin while it's in use. Change-Id: I11c82ce595a336ba0fd1b243d23cb497fe355147 Reviewed-by: Kai Koehne --- src/declarative/debugger/qdeclarativedebugserver.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/declarative/debugger/qdeclarativedebugserver.cpp b/src/declarative/debugger/qdeclarativedebugserver.cpp index 12691b2..fc908f3 100644 --- a/src/declarative/debugger/qdeclarativedebugserver.cpp +++ b/src/declarative/debugger/qdeclarativedebugserver.cpp @@ -95,7 +95,7 @@ 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() : @@ -118,7 +118,7 @@ void QDeclarativeDebugServerPrivate::advertisePlugins() } QDeclarativeDebugServerConnection *QDeclarativeDebugServerPrivate::loadConnectionPlugin( - const QString &pluginName) + QPluginLoader *loader, const QString &pluginName) { #ifndef QT_NO_LIBRARY QStringList pluginCandidates; @@ -135,17 +135,17 @@ QDeclarativeDebugServerConnection *QDeclarativeDebugServerPrivate::loadConnectio } foreach (const QString &pluginPath, pluginCandidates) { - QPluginLoader loader(pluginPath); - if (!loader.load()) { + loader->setFileName(pluginPath); + if (!loader->load()) { continue; } QDeclarativeDebugServerConnection *connection = 0; - if (QObject *instance = loader.instance()) + if (QObject *instance = loader->instance()) connection = qobject_cast(instance); if (connection) return connection; - loader.unload(); + loader->unload(); } #endif return 0; @@ -200,8 +200,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; -- cgit v0.12