diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2023-05-09 16:59:24 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2023-05-12 15:06:42 +0200 |
commit | 13fc038d8d4baa9e199fbd5a7e4c08650a88172e (patch) | |
tree | f0f01ea5594bd3c82a9faa97645c8dbc37b73476 /tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | |
parent | f3b1d6135222e9ce41845a00831a3eb24cd36449 (diff) |
Fix reset support for value types
Our value type refactoring in 6.5 broke reset support for value types
when that write happens through virtualPut.
Fix that by checking whether the value we're assinging is undefined
before attempting any conversion, and reset the gadget in that case (if
it is actually resettable).
Task-number: QTBUG-113473
Pick-to: 6.5
Change-Id: Ifaa2d045f718fc3cb2d5e75b3626b41175ac3a3b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp')
-rw-r--r-- | tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp index edb1e9ba80..98f81c4648 100644 --- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp +++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp @@ -416,6 +416,8 @@ private slots: void doNotCrashOnReadOnlyBindable(); + void resetGadet(); + private: // static void propertyVarWeakRefCallback(v8::Persistent<v8::Value> object, void* parameter); static void verifyContextLifetime(const QQmlRefPointer<QQmlContextData> &ctxt); @@ -10373,6 +10375,20 @@ void tst_qqmlecmascript::doNotCrashOnReadOnlyBindable() QCOMPARE(o->property("x").toInt(), 7); } +void tst_qqmlecmascript::resetGadet() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("resetGadget.qml")); + QVERIFY2(c.isReady(), qPrintable(c.errorString())); + QScopedPointer<QObject> o(c.create()); + QVERIFY(o); + auto resettableGadgetHolder = qobject_cast<ResettableGadgetHolder *>(o.get()); + QVERIFY(resettableGadgetHolder); + QCOMPARE(resettableGadgetHolder->g().value(), 0); + resettableGadgetHolder->setProperty("trigger", QVariant::fromValue(true)); + QCOMPARE(resettableGadgetHolder->g().value(), 42); +} + QTEST_MAIN(tst_qqmlecmascript) #include "tst_qqmlecmascript.moc" |