diff options
author | Kari Oikarinen <kari.oikarinen@qt.io> | 2020-01-15 19:08:34 +0200 |
---|---|---|
committer | Kari Oikarinen <kari.oikarinen@qt.io> | 2020-01-15 19:08:34 +0200 |
commit | 51a158929b55dffbdfb757da8bd6a2cd181906c6 (patch) | |
tree | d887ef986f357614624d65277f94d740c410be21 /tests/auto/qml | |
parent | 3a06d02197179240b8ea589534dc3416c75fc0f2 (diff) | |
parent | 3f8bcced6790059c279430ff34903c16bea25a98 (diff) |
Merge 5.14 into 5.14.1v5.14.1
Change-Id: Iefb900b42cc0476e62342724a5f3a480c09ce354
Diffstat (limited to 'tests/auto/qml')
-rw-r--r-- | tests/auto/qml/qqmlengine/data/evilSingletonInstantiation.qml | 6 | ||||
-rw-r--r-- | tests/auto/qml/qqmlengine/tst_qqmlengine.cpp | 31 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlengine/data/evilSingletonInstantiation.qml b/tests/auto/qml/qqmlengine/data/evilSingletonInstantiation.qml new file mode 100644 index 0000000000..757b0c90bb --- /dev/null +++ b/tests/auto/qml/qqmlengine/data/evilSingletonInstantiation.qml @@ -0,0 +1,6 @@ +import QtQml 2.12 +import foo.foo 1.0 + +QtObject { + objectName: Singleton.objectName +} diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index 64f167b47e..613616ab71 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -83,6 +83,7 @@ private slots: void singletonInstance(); void aggressiveGc(); void cachedGetterLookup_qtbug_75335(); + void createComponentOnSingletonDestruction(); public slots: QObject *createAQObjectForOwnershipTest () @@ -1141,6 +1142,36 @@ void tst_qqmlengine::cachedGetterLookup_qtbug_75335() QVERIFY(object != nullptr); } +class EvilSingleton : public QObject +{ + Q_OBJECT +public: + QPointer<QQmlEngine> m_engine; + EvilSingleton(QQmlEngine *engine) : m_engine(engine) { + connect(this, &QObject::destroyed, this, [this]() { + QQmlComponent component(m_engine); + component.setData("import QtQml 2.0\nQtObject {}", QUrl("file://Stuff.qml")); + QVERIFY(component.isReady()); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(obj); + }); + } +}; + +void tst_qqmlengine::createComponentOnSingletonDestruction() +{ + qmlRegisterSingletonType<EvilSingleton>("foo.foo", 1, 0, "Singleton", + [](QQmlEngine *engine, QJSEngine *) { + return new EvilSingleton(engine); + }); + + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("evilSingletonInstantiation.qml")); + QVERIFY(component.isReady()); + QScopedPointer<QObject> obj(component.create()); + QVERIFY(obj); +} + QTEST_MAIN(tst_qqmlengine) #include "tst_qqmlengine.moc" |