aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2016-06-08 17:32:32 +0200
committerJani Heikkinen <jani.heikkinen@qt.io>2016-06-16 09:26:11 +0000
commit9b1231ca3d21ade574a8a7cf3f0805a8b520bcd5 (patch)
treee5ec8e558b197a30037c2585c6df7c8014d903c8 /tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
parent18e77550f149722e0554f24ddfa326e03a9fef10 (diff)
QML: Only release types if they aren't referenced anymorev5.6.1-1
Just checking for references on m_compiledData is not enough. The actual component can also be referenced. Thus it won't be deleted on release(), but cannot be found in the type cache anymore. Task-number: QTBUG-53761 Change-Id: I8567af8e75a078598e4fed31e4717134e1332278 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> (cherry picked from commit 2ac19881f92c94f4e9427bd9ff513210675f259e)
Diffstat (limited to 'tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp')
-rw-r--r--tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
index 7045c7cbd4..a1eaa0567f 100644
--- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
+++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
@@ -86,10 +86,19 @@ void tst_QQMLTypeLoader::trimCache()
url.setQuery(QString::number(i));
QQmlTypeData *data = loader.getType(url);
- if (i % 5 == 0) // keep references to some of them so that they aren't trimmed
- data->compiledData()->addref();
+ // Run an event loop to receive the callback that release()es.
+ QTRY_COMPARE(data->count(), 2);
- data->release();
+ // keep references to some of them so that they aren't trimmed. References to either the
+ // QQmlTypeData or its compiledData() should prevent the trimming.
+ if (i % 10 == 0) {
+ // keep ref on data, don't add ref on data->compiledData()
+ } else if (i % 5 == 0) {
+ data->compiledData()->addref();
+ data->release();
+ } else {
+ data->release();
+ }
}
for (int i = 0; i < 256; ++i) {