aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-03-19 10:47:24 +0100
committerUlf Hermann <ulf.hermann@qt.io>2018-03-19 12:36:50 +0000
commit8201524ababcf5cb6e14657e23004d45e4dff548 (patch)
tree3804cf98b5f8721baa2df5a518aea2ba567310b0 /tests
parent86702c3be53fda404ebe331207f9062675c952e0 (diff)
QML debugger: Don't crash when creating objects on engine destruction
You can create further objects while the QML engine is being destroyed. The debug service is not interested in those because they will be rather short lived anyway. Task-number: QTBUG-62458 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Change-Id: I255e18590d434e0487efac7c82c223752c645f25 (cherry-picked from commit 958e412a25523cc031564faae81c569aa6c3b01f)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
index 6d31ff9219..9d1aaa4458 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
@@ -141,6 +141,7 @@ private slots:
void queryObjectWithNonStreamableTypes();
void asynchronousCreate();
void invalidContexts();
+ void createObjectOnDestruction();
};
QmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
@@ -1329,6 +1330,29 @@ void tst_QQmlEngineDebugService::invalidContexts()
QCOMPARE(m_dbg->rootContext().contexts.count(), 0);
}
+void tst_QQmlEngineDebugService::createObjectOnDestruction()
+{
+ QSignalSpy spy(m_dbg, SIGNAL(newObject(int)));
+ {
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(
+ "import QtQml 2.0;"
+ "QtObject {"
+ "property Component x:"
+ "Qt.createQmlObject('import QtQml 2.0; Component { QtObject { } }',"
+ "this, 'x.qml');"
+ "Component.onDestruction: x.createObject(this, {});"
+ "}", QUrl::fromLocalFile("x.qml"));
+ QVERIFY(component.isReady());
+ QVERIFY(component.create());
+ QTRY_COMPARE(spy.count(), 2);
+ }
+ // Doesn't crash and doesn't give us another signal for the object created on destruction.
+ QTest::qWait(500);
+ QCOMPARE(spy.count(), 2);
+}
+
int main(int argc, char *argv[])
{
int _argc = argc + 1;