From 4b2eabdf21ff71d557bae36f99cf3998dafe324c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Mon, 8 Feb 2021 16:03:58 +0100 Subject: Return errors if validation of inline components fails Fixes: QTBUG-90038 Change-Id: Ic01b5d097e0b9e6720bcec7ccb18c22abb5418f4 Reviewed-by: Fabian Kosmale (cherry picked from commit 001596d472557bca08eb93159e724301dea88ad6) --- src/qml/qml/qqmlpropertyvalidator.cpp | 4 +++- tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/qml/qml/qqmlpropertyvalidator.cpp b/src/qml/qml/qqmlpropertyvalidator.cpp index 3cc7cc843a..b108884e21 100644 --- a/src/qml/qml/qqmlpropertyvalidator.cpp +++ b/src/qml/qml/qqmlpropertyvalidator.cpp @@ -101,7 +101,9 @@ QVector QQmlPropertyValidator::validateObject( { const QV4::CompiledData::Object *obj = compilationUnit->objectAt(objectIndex); for (auto it = obj->inlineComponentsBegin(); it != obj->inlineComponentsEnd(); ++it) { - validateObject(it->objectIndex, /* instantiatingBinding*/ nullptr); + const auto errors = validateObject(it->objectIndex, /* instantiatingBinding*/ nullptr); + if (!errors.isEmpty()) + return errors; } if (obj->flags & QV4::CompiledData::Object::IsComponent && !(obj->flags & QV4::CompiledData::Object::IsInlineComponentRoot)) { diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index c0286bd195..bf818b9005 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -344,6 +344,8 @@ private slots: void factorySingleton(); void extendedSingleton(); + void invalidInlineComponent(); + private: QQmlEngine engine; QStringList defaultImportPathList; @@ -6087,6 +6089,22 @@ void tst_qqmllanguage::extendedSingleton() QCOMPARE(obj->property("d").toInt(), 9); } +void tst_qqmllanguage::invalidInlineComponent() +{ + QQmlEngine e; + QQmlComponent c(&engine); + c.setData("import QtQuick 2.0\n" + "import QtQuick.Window 2.1\n" + "Window {\n" + " component TestPopup: Window {\n" + " visibility: Window.Windowed\n" + " }\n" + " TestPopup { color: \"blue\" }\n" + "}", QUrl()); + QVERIFY(c.isError()); + QVERIFY(c.errorString().contains("\"Window.visibility\" is not available in QtQuick 2.0.")); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" -- cgit v1.2.3