aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-11-05 12:43:18 +0100
committerUlf Hermann <ulf.hermann@qt.io>2020-11-06 22:41:48 +0100
commit68b9ab7b93320a975c2f20c09eddccf0fdb275b7 (patch)
treea5fbfac67de97a30c2c024c1c98948fcc77596df /tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
parente5b14cd18e84b5c9f2a85d82c2af8ffba376988e (diff)
V4: Prevent heap objects from getting immediately swept by GC
A destruction handler can cause a new object to be allocated during garbage collection. Depending on where in the heap the object ends up, it may be found during the sweep pass. As the mark pass had no chance to mark the object, we need to set the mark bit right at allocation time in this case. Change-Id: Ie43eeb548e78bd375b001b3a6bb4ef6596f91980 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 96fdd012e2..985b8c7a98 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -7676,7 +7676,10 @@ void tst_qqmlecmascript::onDestructionViaGC()
gc(engine);
QVERIFY2(mutatorResult, "We failed to re-assign the weak reference a new value during GC");
- QVERIFY2(sentinelResult, "The weak reference was not cleared properly");
+ QVERIFY2(!sentinelResult, "The weak value was cleared on first GC run");
+ QVERIFY2(!weakRef->isNullOrUndefined(), "The weak value was cleared on first GC run");
+ gc(engine);
+ QVERIFY2(weakRef->isNullOrUndefined(), "The weak value was not cleared on second gc run");
}
struct EventProcessor : public QObject