tst_qqmlengine: Further stabilize

Not only C++ and JS singletons, but also QML singletons can be created
in the same memory location ...

Amends commit c300a170ed
Amends commit e1614a41c8

Pick-to: 6.10 6.9 6.8
Change-Id: If4ce39287e459d5b183f044fd8e7bbca52b639b7
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Ulf Hermann 2025-09-05 12:59:55 +02:00
parent 2529e09712
commit 93624bce20
1 changed files with 4 additions and 2 deletions

View File

@ -606,8 +606,10 @@ QT_WARNING_POP
const JsSingleton *oldJsSingleton = engine.singletonInstance<JsSingleton *>(jsObject);
QVERIFY(oldJsSingleton != nullptr);
const uint oldJsSingletonId = oldJsSingleton->id;
const QObject *oldQmlSingleton = engine.singletonInstance<QObject *>(qmlObject);
QObject *oldQmlSingleton = engine.singletonInstance<QObject *>(qmlObject);
QVERIFY(oldQmlSingleton != nullptr);
QCOMPARE(oldQmlSingleton->objectName(), "theSingleton");
oldQmlSingleton->setObjectName("marked");
QQmlComponent c(&engine);
c.setData("import ClearSingletons\n"
@ -665,7 +667,7 @@ QT_WARNING_POP
QVERIFY(newJsSingleton->id != oldJsSingletonId);
const QObject *newQmlSingleton = engine.singletonInstance<QObject *>(qmlObject);
QVERIFY(newQmlSingleton != nullptr);
QVERIFY(newQmlSingleton != oldQmlSingleton);
QCOMPARE(newQmlSingleton->objectName(), "theSingleton");
// Holding on to an old singleton instance is OK. We don't delete those.
QCOMPARE(qvariant_cast<QObject *>(singletonUser->property("a")), &objectCaller1);