From 16316391948b09c7249b5094493eeef6b869d9bc Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 17 Nov 2011 15:27:04 +0000 Subject: Fix crash in incubator when a guarded context is deleted Change-Id: Ice7375c344b7e8d0d11cc6ee0bdfdf864ecd7109 Reviewed-by: Kent Hansen --- .../qdeclarativeincubator/data/contextDelete.qml | 5 +++++ .../tst_qdeclarativeincubator.cpp | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 tests/auto/declarative/qdeclarativeincubator/data/contextDelete.qml (limited to 'tests') diff --git a/tests/auto/declarative/qdeclarativeincubator/data/contextDelete.qml b/tests/auto/declarative/qdeclarativeincubator/data/contextDelete.qml new file mode 100644 index 0000000000..c3952074f1 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeincubator/data/contextDelete.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +QtObject { + property int dummy: 12 +} diff --git a/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp b/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp index 54ca622753..efa46264c3 100644 --- a/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp +++ b/tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -85,6 +86,7 @@ private slots: void chainedAsynchronousIfNested(); void chainedAsynchronousIfNestedOnCompleted(); void selfDelete(); + void contextDelete(); private: QDeclarativeIncubationController controller; @@ -975,6 +977,24 @@ void tst_qdeclarativeincubator::selfDelete() } } +// Test that QML doesn't crash if the context is deleted prior to the incubator +// first executing. +void tst_qdeclarativeincubator::contextDelete() +{ + QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext()); + QDeclarativeComponent component(&engine, TEST_FILE("contextDelete.qml")); + + QDeclarativeIncubator incubator; + component.create(incubator, context); + + delete context; + + { + bool b = false; + controller.incubateWhile(&b); + } +} + QTEST_MAIN(tst_qdeclarativeincubator) #include "tst_qdeclarativeincubator.moc" -- cgit v1.2.3