aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Brasser <mbrasser@ford.com>2017-12-21 11:03:53 -0600
committerMichael Brasser <michael.brasser@live.com>2017-12-29 02:30:32 +0000
commit78a5add79497300802c2152b5bf561b6bef305f1 (patch)
tree4840dfc5d192ac57d3c3faae91ec791ae1d8d84d /tests
parent6f6fa9ee929292639a24f2b15c432a41df92610d (diff)
Remove extra addref
The code was previously updated to use QQmlRefPointer, so we shouldn't explicitly addref. This allows more components to be correctly trimmed when needed. Change-Id: I15a961cfc456eeab5c791c8a282cc7e2852912cb Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmltypeloader/data/ComponentWithIncubator.qml9
-rw-r--r--tests/auto/qml/qqmltypeloader/data/trim_cache3.qml14
-rw-r--r--tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp21
3 files changed, 44 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmltypeloader/data/ComponentWithIncubator.qml b/tests/auto/qml/qqmltypeloader/data/ComponentWithIncubator.qml
new file mode 100644
index 0000000000..b3610831df
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/ComponentWithIncubator.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+
+Item {
+ Repeater {
+ model: 3
+ Item {}
+ }
+}
+
diff --git a/tests/auto/qml/qqmltypeloader/data/trim_cache3.qml b/tests/auto/qml/qqmltypeloader/data/trim_cache3.qml
new file mode 100644
index 0000000000..219c7d3bcb
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/trim_cache3.qml
@@ -0,0 +1,14 @@
+import QtQuick 2.0
+
+Item {
+ width: 400
+ height: 400
+
+ property alias source: loader.source
+
+ Loader {
+ id: loader
+ source: "ComponentWithIncubator.qml"
+ }
+}
+
diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
index 5ab729042f..5a3d76e903 100644
--- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
+++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
@@ -44,6 +44,7 @@ private slots:
void loadComponentSynchronously();
void trimCache();
void trimCache2();
+ void trimCache3();
void keepSingleton();
void keepRegistrations();
void intercept();
@@ -124,6 +125,26 @@ void tst_QQMLTypeLoader::trimCache2()
QCOMPARE(loader.isTypeLoaded(testFileUrl("MyComponent2.qml")), false);
}
+// test trimming the cache of an item that contains sub-items created via incubation
+void tst_QQMLTypeLoader::trimCache3()
+{
+ QScopedPointer<QQuickView> window(new QQuickView());
+ window->setSource(testFileUrl("trim_cache3.qml"));
+ QQmlTypeLoader &loader = QQmlEnginePrivate::get(window->engine())->typeLoader;
+ QCOMPARE(loader.isTypeLoaded(testFileUrl("ComponentWithIncubator.qml")), true);
+
+ QQmlProperty::write(window->rootObject(), "source", QString());
+
+ // handle our deleteLater and cleanup
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
+ QCoreApplication::processEvents();
+ window->engine()->collectGarbage();
+
+ window->engine()->trimComponentCache();
+
+ QCOMPARE(loader.isTypeLoaded(testFileUrl("ComponentWithIncubator.qml")), false);
+}
+
static void checkSingleton(const QString &dataDirectory)
{
QQmlEngine engine;