tst_qqmlengine: Further stabilize
Not only C++ and JS singletons, but also QML singletons can be created in the same memory location ... Amends commitc300a170ed
Amends commite1614a41c8
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:
parent
2529e09712
commit
93624bce20
|
@ -606,8 +606,10 @@ QT_WARNING_POP
|
||||||
const JsSingleton *oldJsSingleton = engine.singletonInstance<JsSingleton *>(jsObject);
|
const JsSingleton *oldJsSingleton = engine.singletonInstance<JsSingleton *>(jsObject);
|
||||||
QVERIFY(oldJsSingleton != nullptr);
|
QVERIFY(oldJsSingleton != nullptr);
|
||||||
const uint oldJsSingletonId = oldJsSingleton->id;
|
const uint oldJsSingletonId = oldJsSingleton->id;
|
||||||
const QObject *oldQmlSingleton = engine.singletonInstance<QObject *>(qmlObject);
|
QObject *oldQmlSingleton = engine.singletonInstance<QObject *>(qmlObject);
|
||||||
QVERIFY(oldQmlSingleton != nullptr);
|
QVERIFY(oldQmlSingleton != nullptr);
|
||||||
|
QCOMPARE(oldQmlSingleton->objectName(), "theSingleton");
|
||||||
|
oldQmlSingleton->setObjectName("marked");
|
||||||
|
|
||||||
QQmlComponent c(&engine);
|
QQmlComponent c(&engine);
|
||||||
c.setData("import ClearSingletons\n"
|
c.setData("import ClearSingletons\n"
|
||||||
|
@ -665,7 +667,7 @@ QT_WARNING_POP
|
||||||
QVERIFY(newJsSingleton->id != oldJsSingletonId);
|
QVERIFY(newJsSingleton->id != oldJsSingletonId);
|
||||||
const QObject *newQmlSingleton = engine.singletonInstance<QObject *>(qmlObject);
|
const QObject *newQmlSingleton = engine.singletonInstance<QObject *>(qmlObject);
|
||||||
QVERIFY(newQmlSingleton != nullptr);
|
QVERIFY(newQmlSingleton != nullptr);
|
||||||
QVERIFY(newQmlSingleton != oldQmlSingleton);
|
QCOMPARE(newQmlSingleton->objectName(), "theSingleton");
|
||||||
|
|
||||||
// Holding on to an old singleton instance is OK. We don't delete those.
|
// Holding on to an old singleton instance is OK. We don't delete those.
|
||||||
QCOMPARE(qvariant_cast<QObject *>(singletonUser->property("a")), &objectCaller1);
|
QCOMPARE(qvariant_cast<QObject *>(singletonUser->property("a")), &objectCaller1);
|
||||||
|
|
Loading…
Reference in New Issue