diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativeincubator/data/contextDelete.qml | 5 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativeincubator/tst_qdeclarativeincubator.cpp | 20 |
2 files changed, 25 insertions, 0 deletions
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 <QPointer> #include <QFileInfo> #include <QDeclarativeEngine> +#include <QDeclarativeContext> #include <QDeclarativeProperty> #include <QDeclarativeComponent> #include <QDeclarativeIncubator> @@ -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" |