aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2019-01-03 10:36:44 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-01-03 10:21:27 +0000
commitc327c43be82c6a2827df1f493ca4e3487a0fc9c3 (patch)
tree95e0de9b50ff8ddb6d003fe9a52b773a1f5744a5 /tests
parent0e33ba51166dd68a26c56d85a1155c4849d59e4a (diff)
Tests: Don't capture stack value by reference
We can actually not capture d at all there, as some of the items get deleted before the root object is deleted. Therefore, we need to iterate the children again on receiving the destroyed() signal. Change-Id: Iab7ebc3c731438a21b243284de7515530232828f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
index 89640bc385..cb4bee0d3a 100644
--- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
+++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
@@ -883,13 +883,13 @@ void tst_qqmlcontext::contextObjectHierarchy()
QScopedPointer<QObject> root(component.create());
QVERIFY(!root.isNull());
- for (const QObject *child : root->children()) {
- QQmlData *d = QQmlData::get(child);
- QVERIFY(d->outerContext != nullptr);
- connect(root.data(), &QObject::destroyed, [&]() {
- QCOMPARE(d->outerContext, nullptr);
- });
- }
+ for (const QObject *child : root->children())
+ QVERIFY(QQmlData::get(child)->outerContext != nullptr);
+
+ connect(root.data(), &QObject::destroyed, [&root]() {
+ for (const QObject *child : root->children())
+ QCOMPARE(QQmlData::get(child)->outerContext, nullptr);
+ });
}
QTEST_MAIN(tst_qqmlcontext)