From 4d098132421fe75492d61d270569c2d8a7acbdde Mon Sep 17 00:00:00 2001 From: Richard Weickelt Date: Sun, 21 Apr 2019 13:27:05 +0200 Subject: 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() 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 --- tools/qmlplugindump/main.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'tools') 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 collectReachableMetaObjects(QQmlEngine *engine, << " is singleton, but has no singletonInstanceInfo" << std::endl; continue; } - 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(ty); } else { inObjectInstantiation.clear(); continue; // we don't handle QJSValue singleton types. -- cgit v1.2.3