path: root/tools
diff options
authorRichard Weickelt <>2019-04-21 13:27:05 +0200
committerRichard Weickelt <>2019-04-24 08:43:00 +0000
commit4d098132421fe75492d61d270569c2d8a7acbdde (patch)
treea94712d523c82b88d7668b6f71879f88d33c682b /tools
parent93818a359973003531e2a5ef2d55cf58b3d440d9 (diff)
Move creation and management of singletons to QQmlEnginePrivate
Singleton object instances were previously managed by QQmlType::SingletonInstanceInfo and kept in a shared storage. This caused concurrency problems when instantiating singleton instances from different QML engines in different threads. This patch moves the singleton house-keeping infrastructure to QQmlEnginePrivate and makes SingletonInstanceInfo immutable. Singleton objects are stored in a QHash with QQmlType as the key because the qml type id might be 0 for composite singletons. The public API of QQmlType is extended to provide more information about singleton types so that access to SingletonInstanceInfo is not needed. All internal accesses of singleton objects must now take the same code path via QQmlEnginePrivate::singletonInstance<T>() which simplifies overall usage of singletons and scatters less implementation details throughout the code base. Task-number: QTBUG-75007 Change-Id: I13c5fd21cac2eb7291f2cbcf2c2b504f0f51a07c Reviewed-by: Ulf Hermann <>
Diffstat (limited to 'tools')
1 files changed, 2 insertions, 3 deletions
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index f3b931fbbf..ccdab57cfc 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -270,13 +270,12 @@ QSet<const QMetaObject *> collectReachableMetaObjects(QQmlEngine *engine,
<< " is singleton, but has no singletonInstanceInfo" << std::endl;
- if (siinfo->qobjectCallback) {
+ if (ty.isQObjectSingleton()) {
if (verbose)
std::cerr << "Trying to get singleton for " << qPrintable(tyName)
<< " (" << qPrintable( siinfo->typeName ) << ")" << std::endl;
- siinfo->init(engine);
collectReachableMetaObjects(object, &metas);
- object = siinfo->qobjectApi(engine);
+ object = QQmlEnginePrivate::get(engine)->singletonInstance<QObject*>(ty);
} else {
continue; // we don't handle QJSValue singleton types.