From c14c382e6e8527be1129788ccca31309b032f99c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Aug 2016 12:57:58 -0500 Subject: Allow for garbage collection of types with errors in trimCache() Change-Id: I821ea14f60871735bface4e2cf4e61fcb61b2784 Task-number: QTBUG-55567 Reviewed-by: Michael Brasser Reviewed-by: Ulf Hermann --- tests/auto/qml/qqmltypeloader/data/MyComponent.qml | 11 +++++++++++ tests/auto/qml/qqmltypeloader/data/MyComponent2.qml | 7 +++++++ tests/auto/qml/qqmltypeloader/data/MyComponent3.qml | 9 +++++++++ tests/auto/qml/qqmltypeloader/data/trim_cache2.qml | 13 +++++++++++++ tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp | 14 ++++++++++++++ 5 files changed, 54 insertions(+) create mode 100644 tests/auto/qml/qqmltypeloader/data/MyComponent.qml create mode 100644 tests/auto/qml/qqmltypeloader/data/MyComponent2.qml create mode 100644 tests/auto/qml/qqmltypeloader/data/MyComponent3.qml create mode 100644 tests/auto/qml/qqmltypeloader/data/trim_cache2.qml (limited to 'tests') diff --git a/tests/auto/qml/qqmltypeloader/data/MyComponent.qml b/tests/auto/qml/qqmltypeloader/data/MyComponent.qml new file mode 100644 index 0000000000..a642518199 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/MyComponent.qml @@ -0,0 +1,11 @@ +import QtQuick 2.0 + +Rectangle { + width: 100 + height: 62 + + MyComponent3 {} + + MyComponent2 {} +} + diff --git a/tests/auto/qml/qqmltypeloader/data/MyComponent2.qml b/tests/auto/qml/qqmltypeloader/data/MyComponent2.qml new file mode 100644 index 0000000000..02cf5cb5dd --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/MyComponent2.qml @@ -0,0 +1,7 @@ +import QtQuick 2.0 + +Rectangle { + width: 100 + height: 62 +} + diff --git a/tests/auto/qml/qqmltypeloader/data/MyComponent3.qml b/tests/auto/qml/qqmltypeloader/data/MyComponent3.qml new file mode 100644 index 0000000000..ad5d569197 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/MyComponent3.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 + +Rectangle { + width: 100 + height: 62 + + MyComponent4 {} +} + diff --git a/tests/auto/qml/qqmltypeloader/data/trim_cache2.qml b/tests/auto/qml/qqmltypeloader/data/trim_cache2.qml new file mode 100644 index 0000000000..326a720a87 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/trim_cache2.qml @@ -0,0 +1,13 @@ +import QtQuick 2.0 + +Item { + width: 400 + height: 400 + + Component.onCompleted: { + var component = Qt.createComponent("MyComponent.qml") + if (component.status == Component.Error) + console.log(component.errorString()) + } +} + diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index a1eaa0567f..8eb413e9f7 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -48,6 +48,7 @@ private slots: void testLoadComplete(); void loadComponentSynchronously(); void trimCache(); + void trimCache2(); }; void tst_QQMLTypeLoader::testLoadComplete() @@ -112,6 +113,19 @@ void tst_QQMLTypeLoader::trimCache() } } +void tst_QQMLTypeLoader::trimCache2() +{ + QQuickView *window = new QQuickView(); + window->setSource(testFileUrl("trim_cache2.qml")); + QQmlTypeLoader &loader = QQmlEnginePrivate::get(window->engine())->typeLoader; + // in theory if gc has already run this could be false + // QCOMPARE(loader.isTypeLoaded(testFileUrl("MyComponent2.qml")), true); + window->engine()->collectGarbage(); + QTest::qWait(1); // force event loop + window->engine()->trimComponentCache(); + QCOMPARE(loader.isTypeLoaded(testFileUrl("MyComponent2.qml")), false); +} + QTEST_MAIN(tst_QQMLTypeLoader) #include "tst_qqmltypeloader.moc" -- cgit v1.2.3