aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcontext
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-07-02 13:21:41 +0200
committerUlf Hermann <ulf.hermann@qt.io>2019-07-03 08:55:56 +0200
commit1a0c2fb5bdaed175c9d9472b0658f93214572d4d (patch)
treea08d4fc28d96c1ea81f43d43b3939f7c7acba368 /tests/auto/qml/qqmlcontext
parent64c1fbe96c68b1286a70242ff4922be140128cb2 (diff)
When setting a QObject as context property reset it when it's destroyed
Fixes: QTBUG-76346 Change-Id: Ie21f831a775489f0f2ac2e296136ed4932f5154f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlcontext')
-rw-r--r--tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
index cb4bee0d3a..d9cb6673df 100644
--- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
+++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
@@ -71,6 +71,7 @@ private slots:
void outerContextObject();
void contextObjectHierarchy();
+ void destroyContextProperty();
private:
QQmlEngine engine;
@@ -892,6 +893,20 @@ void tst_qqmlcontext::contextObjectHierarchy()
});
}
+void tst_qqmlcontext::destroyContextProperty()
+{
+ QQmlEngine engine;
+ QQmlContext context(&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);
+}
+
QTEST_MAIN(tst_qqmlcontext)
#include "tst_qqmlcontext.moc"