aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2016-06-08 17:32:32 +0200
committerLiang Qi <liang.qi@qt.io>2016-06-10 19:16:45 +0000
commit2ac19881f92c94f4e9427bd9ff513210675f259e (patch)
treec947c81adecbde744ac9e6e325bf6ea66af45c40 /tests
parent56d9505e9d2b7dd9507523693d81f72efaa247c8 (diff)
QML: Only release types if they aren't referenced anymore
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>
Diffstat (limited to 'tests')
-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) {