aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcontext
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2019-11-18 16:15:01 +0100
committerLeander Beernaert <leander.beernaert@qt.io>2019-11-25 15:34:40 +0100
commitf1f395b37da163bce2dc3b5fc4e298bb4f56a3e7 (patch)
tree9ce2ba89a86ed754a8ecb8f52181770853e21a08 /tests/auto/qml/qqmlcontext
parentba494aaa24defe1401f621b791891e696b308756 (diff)
parent0ee087f5a5edd7d1aa39fd15e0dc85985320c09a (diff)
Merge remote-tracking branch 'origin/dev' into wip/cmake
Diffstat (limited to 'tests/auto/qml/qqmlcontext')
-rw-r--r--tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
index d9cb6673df..6754f22049 100644
--- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
+++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
@@ -895,16 +895,27 @@ void tst_qqmlcontext::contextObjectHierarchy()
void tst_qqmlcontext::destroyContextProperty()
{
- QQmlEngine engine;
- QQmlContext context(&engine);
-
+ QScopedPointer<QQmlContext> context;
+ QScopedPointer<QObject> objectThatOutlivesEngine(new QObject);
{
- QObject object;
- context.setContextProperty(QLatin1String("a"), &object);
- QCOMPARE(qvariant_cast<QObject *>(context.contextProperty(QLatin1String("a"))), &object);
+ QQmlEngine engine;
+ context.reset(new QQmlContext(&engine));
+
+ {
+ QObject object;
+ context->setContextProperty(QLatin1String("a"), &object);
+ QCOMPARE(qvariant_cast<QObject *>(context->contextProperty(QLatin1String("a"))), &object);
+ }
+
+ QCOMPARE(qvariant_cast<QObject *>(context->contextProperty(QLatin1String("a"))), nullptr);
+ context->setContextProperty(QLatin1String("b"), objectThatOutlivesEngine.data());
}
- QCOMPARE(qvariant_cast<QObject *>(context.contextProperty(QLatin1String("a"))), nullptr);
+ // dropDestroyedObject() should not crash, even if the engine is gone.
+ objectThatOutlivesEngine.reset();
+
+ // We're not allowed to call context->contextProperty("b") anymore.
+ // TODO: Or are we?
}
QTEST_MAIN(tst_qqmlcontext)