diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-02-14 12:24:55 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-02-14 16:05:27 +0100 |
commit | 6937f2e50dd60c58350a464eb83ba9d11c7146f9 (patch) | |
tree | 7fc9b5e74998e8d026d3f19924ed077e188b6325 /tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp | |
parent | 93956372d9bce55d3bc67690783697a2f2471694 (diff) | |
download | qtdeclarative-6937f2e50dd60c58350a464eb83ba9d11c7146f9.tar.gz |
QQmlMetaType: Clear property caches on qmlClearTypeRegistrations
Otherwise we may retain dangling pointers referencing invalid property
caches. Some metaobjects are created on the heap. If the memory manager
decides to re-use the heap space for new metaobjects, we can retrieve
the invalid property caches.
Pick-to: 6.5 6.4 6.2
Task-number: QTBUG-110933
Change-Id: Ic00bb852151bcf58ba6ae798a6bf2cea686a9e10
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp')
-rw-r--r-- | tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp index c1bac33d87..a185f1776f 100644 --- a/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp +++ b/tests/auto/qml/qqmlmetatype/tst_qqmlmetatype.cpp @@ -51,6 +51,8 @@ private slots: void enumsInRecursiveImport(); void revertValueTypeAnimation(); + + void clearPropertyCaches(); }; class TestType : public QObject @@ -724,6 +726,18 @@ void tst_qqmlmetatype::revertValueTypeAnimation() QCOMPARE(o->property("pointSize").toDouble(), 12.0); } +void tst_qqmlmetatype::clearPropertyCaches() +{ + qmlClearTypeRegistrations(); + qmlRegisterType<TestType>("ClearPropertyCaches", 1, 0, "A"); + QQmlPropertyCache::ConstPtr oldCache = QQmlMetaType::propertyCache(&TestType::staticMetaObject); + QVERIFY(oldCache); + qmlClearTypeRegistrations(); + qmlRegisterType<TestType>("ClearPropertyCaches", 1, 0, "B"); + QQmlPropertyCache::ConstPtr newCache = QQmlMetaType::propertyCache(&TestType::staticMetaObject); + QVERIFY(oldCache.data() != newCache.data()); +} + QTEST_MAIN(tst_qqmlmetatype) #include "tst_qqmlmetatype.moc" |