diff options
author | Jaeyoon Jung <jaeyoon.jung@lge.com> | 2018-02-08 14:24:20 +0900 |
---|---|---|
committer | Dominik Holland <dominik.holland@qt.io> | 2020-06-10 12:51:53 +0200 |
commit | f0c08dc2175cffadb73e06d2cc69a152002e0df0 (patch) | |
tree | c63999753847ef1b251a0d5b156a75f8d386ddb5 /tests/auto/qml/qqmltypeloader | |
parent | bba1b19a18a04060942e5580e36daccf9c830b61 (diff) |
Warn circular dependency when loading types
Detect a circular dependency between two QML types and print a warning
message if found.
Task-number: QTBUG-83354
Pick-to: 5.15
Change-Id: I826b28775ba3212ccccaeb56d50b64fec6f38ea9
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmltypeloader')
3 files changed, 15 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmltypeloader/data/CircularDependency.qml b/tests/auto/qml/qqmltypeloader/data/CircularDependency.qml new file mode 100644 index 0000000000..0b7c030063 --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/CircularDependency.qml @@ -0,0 +1,3 @@ +import QtQml 2.0 + +CircularDependencyBase {} diff --git a/tests/auto/qml/qqmltypeloader/data/CircularDependencyBase.qml b/tests/auto/qml/qqmltypeloader/data/CircularDependencyBase.qml new file mode 100644 index 0000000000..d068d1cabc --- /dev/null +++ b/tests/auto/qml/qqmltypeloader/data/CircularDependencyBase.qml @@ -0,0 +1,3 @@ +import QtQml 2.0 + +CircularDependency {} diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp index c7792ec4f5..3843d9a720 100644 --- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp +++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp @@ -63,6 +63,7 @@ private slots: void implicitImport(); void compositeSingletonCycle(); void declarativeCppType(); + void circularDependency(); private: void checkSingleton(const QString & dataDirectory); }; @@ -610,6 +611,14 @@ void tst_QQMLTypeLoader::declarativeCppType() QVERIFY(!obj.isNull()); } +void tst_QQMLTypeLoader::circularDependency() +{ + QQmlEngine engine; + QTest::ignoreMessage(QtWarningMsg, QRegularExpression("Cyclic dependency detected between (.*) and (.*)")); + QQmlComponent component(&engine, testFileUrl("CircularDependency.qml")); + QCOMPARE(component.status(), QQmlComponent::Null); +} + QTEST_MAIN(tst_QQMLTypeLoader) #include "tst_qqmltypeloader.moc" |