aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp3
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp24
2 files changed, 26 insertions, 1 deletions
diff --git a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
index d2934ba034..507f12cf3a 100644
--- a/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_debugger/qqmlenginedebugservice.cpp
@@ -812,7 +812,8 @@ void QQmlEngineDebugServiceImpl::engineAboutToBeRemoved(QJSEngine *engine)
void QQmlEngineDebugServiceImpl::objectCreated(QJSEngine *engine, QObject *object)
{
Q_ASSERT(engine);
- Q_ASSERT(m_engines.contains(engine));
+ if (!m_engines.contains(engine))
+ return;
int engineId = QQmlDebugService::idForObject(engine);
int objectId = QQmlDebugService::idForObject(object);
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;