diff options
Diffstat (limited to 'tests/auto/qml/qqmlincubator')
-rw-r--r-- | tests/auto/qml/qqmlincubator/CMakeLists.txt | 6 | ||||
-rw-r--r-- | tests/auto/qml/qqmlincubator/data/garbageCollection2.qml | 12 | ||||
-rw-r--r-- | tests/auto/qml/qqmlincubator/testtypes.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlincubator/testtypes.h | 2 | ||||
-rw-r--r-- | tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp | 12 |
5 files changed, 29 insertions, 5 deletions
diff --git a/tests/auto/qml/qqmlincubator/CMakeLists.txt b/tests/auto/qml/qqmlincubator/CMakeLists.txt index 230609bb1d..3a38868e76 100644 --- a/tests/auto/qml/qqmlincubator/CMakeLists.txt +++ b/tests/auto/qml/qqmlincubator/CMakeLists.txt @@ -7,6 +7,12 @@ ## tst_qqmlincubator Test: ##################################################################### +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qqmlincubator LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + # Collect test data file(GLOB_RECURSE test_data_glob RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/tests/auto/qml/qqmlincubator/data/garbageCollection2.qml b/tests/auto/qml/qqmlincubator/data/garbageCollection2.qml new file mode 100644 index 0000000000..b5ba531ede --- /dev/null +++ b/tests/auto/qml/qqmlincubator/data/garbageCollection2.qml @@ -0,0 +1,12 @@ +import QtQml +QtObject { + property Component comp: Component { + QtObject {} + } + + property QtObject incubated: { + var i = comp.incubateObject(null, {}, Qt.Synchronous); + gc(); + return i.object + } +} diff --git a/tests/auto/qml/qqmlincubator/testtypes.cpp b/tests/auto/qml/qqmlincubator/testtypes.cpp index c94ef73c20..4e449a1b5a 100644 --- a/tests/auto/qml/qqmlincubator/testtypes.cpp +++ b/tests/auto/qml/qqmlincubator/testtypes.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "testtypes.h" #include <QtQml/qqml.h> diff --git a/tests/auto/qml/qqmlincubator/testtypes.h b/tests/auto/qml/qqmlincubator/testtypes.h index e4c48d9d13..4942957986 100644 --- a/tests/auto/qml/qqmlincubator/testtypes.h +++ b/tests/auto/qml/qqmlincubator/testtypes.h @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #ifndef TESTTYPES_H #define TESTTYPES_H diff --git a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp index 1baf61574e..948dc66e71 100644 --- a/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp +++ b/tests/auto/qml/qqmlincubator/tst_qqmlincubator.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "testtypes.h" #include <QUrl> @@ -1148,7 +1148,7 @@ void tst_qqmlincubator::garbageCollection() QQmlComponent component(&engine, testFileUrl("garbageCollection.qml")); QScopedPointer<QObject> obj(component.create()); - engine.collectGarbage(); + gc(engine); std::atomic<bool> b{true}; controller.incubateWhile(&b); @@ -1166,8 +1166,14 @@ void tst_qqmlincubator::garbageCollection() incubatorVariant.clear(); // verify incubator is correctly collected now that incubation is complete and all references are gone - engine.collectGarbage(); + gc(engine); QVERIFY(weakIncubatorRef.isNullOrUndefined()); + + QQmlComponent component2(&engine, testFileUrl("garbageCollection2.qml")); + QVERIFY2(component2.isReady(), qPrintable(component2.errorString())); + QScopedPointer<QObject> obj2(component2.create()); + QVERIFY(!obj2.isNull()); + QVERIFY(obj2->property("incubated").value<QObject *>() != nullptr); } void tst_qqmlincubator::requiredProperties() |