diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2019-11-07 14:26:20 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2019-11-07 16:10:50 +0100 |
commit | 1f63d5331f5b0e7195407c2276a61f9e072c325b (patch) | |
tree | ff0265726bf212c412b5ebb6c36c2c20ed00434d /tests/auto/qml/qqmltypeloader | |
parent | ce40ac9ed7255c36acdee69b06a7832e492c3fc8 (diff) |
tst_qqmltypeloader: Avoid memory leaks
Change-Id: I65cd3cd78b072b0b3508e1e9fa8e88e1a6b32255
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmltypeloader')
-rw-r--r-- | tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index e90f53d389..36af253fa0 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -95,6 +95,8 @@ void tst_QQMLTypeLoader::trimCache() { QQmlEngine engine; QQmlTypeLoader &loader = QQmlEnginePrivate::get(&engine)->typeLoader; + QVector<QQmlTypeData *> releaseLater; + QVector<QV4::ExecutableCompilationUnit *> releaseCompilationUnitLater; for (int i = 0; i < 256; ++i) { QUrl url = testFileUrl("trim_cache.qml"); url.setQuery(QString::number(i)); @@ -107,8 +109,10 @@ void tst_QQMLTypeLoader::trimCache() // QQmlTypeData or its compiledData() should prevent the trimming. if (i % 10 == 0) { // keep ref on data, don't add ref on data->compiledData() + releaseLater.append(data); } else if (i % 5 == 0) { data->compilationUnit()->addref(); + releaseCompilationUnitLater.append(data->compilationUnit()); data->release(); } else { data->release(); @@ -124,6 +128,12 @@ void tst_QQMLTypeLoader::trimCache() QVERIFY(!loader.isTypeLoaded(url)); // The cache is free to keep the others. } + + for (auto *data : qAsConst(releaseCompilationUnitLater)) + data->release(); + + for (auto *data : qAsConst(releaseLater)) + data->release(); } void tst_QQMLTypeLoader::trimCache2() |