aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/qml/qqmlcomponent.cpp5
-rw-r--r--tests/auto/qml/qqmllanguage/data/GroupFailureInner.qml2
-rw-r--r--tests/auto/qml/qqmllanguage/data/GroupFailureOuter.qml5
-rw-r--r--tests/auto/qml/qqmllanguage/data/groupFailure.qml5
-rw-r--r--tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp16
5 files changed, 32 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 63305620b9..f936225066 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -345,6 +345,7 @@ void QQmlComponentPrivate::fromTypeData(const QQmlRefPointer<QQmlTypeData> &data
RequiredProperties &QQmlComponentPrivate::requiredProperties()
{
+ Q_ASSERT(state.creator);
return state.creator->requiredProperties();
}
@@ -447,7 +448,9 @@ QQmlComponent::~QQmlComponent()
qWarning().nospace().noquote() << QLatin1String(" ") << error;
}
- d->completeCreate();
+ // we might not have the creator anymore if the engine is gone
+ if (d->state.creator)
+ d->completeCreate();
}
if (d->typeData) {
diff --git a/tests/auto/qml/qqmllanguage/data/GroupFailureInner.qml b/tests/auto/qml/qqmllanguage/data/GroupFailureInner.qml
new file mode 100644
index 0000000000..7972cc9683
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/GroupFailureInner.qml
@@ -0,0 +1,2 @@
+import QtQml
+QtObject { property url u }
diff --git a/tests/auto/qml/qqmllanguage/data/GroupFailureOuter.qml b/tests/auto/qml/qqmllanguage/data/GroupFailureOuter.qml
new file mode 100644
index 0000000000..2a34a29789
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/GroupFailureOuter.qml
@@ -0,0 +1,5 @@
+import QtQml
+
+QtObject {
+ property GroupFailureInner b
+}
diff --git a/tests/auto/qml/qqmllanguage/data/groupFailure.qml b/tests/auto/qml/qqmllanguage/data/groupFailure.qml
new file mode 100644
index 0000000000..e8f8999482
--- /dev/null
+++ b/tests/auto/qml/qqmllanguage/data/groupFailure.qml
@@ -0,0 +1,5 @@
+import QtQml
+
+GroupFailureOuter {
+ b.u: null
+}
diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
index e41706a348..6a3254e52d 100644
--- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
+++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp
@@ -249,6 +249,8 @@ private slots:
void deepProperty();
+ void groupAssignmentFailure();
+
void compositeSingletonProperties();
void compositeSingletonSameEngine();
void compositeSingletonDifferentEngine();
@@ -4412,6 +4414,20 @@ void tst_qqmllanguage::deepProperty()
QCOMPARE(font.family(), QStringLiteral("test"));
}
+void tst_qqmllanguage::groupAssignmentFailure()
+{
+ auto ep = std::make_unique<QQmlEngine>();
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, "QQmlComponent: Component destroyed while completion pending");
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, "This may have been caused by one of the following errors:");
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, QRegularExpression(".*Cannot set properties on b as it is null.*"));
+ QTest::ignoreMessage(QtMsgType::QtWarningMsg, QRegularExpression(".*Invalid property assignment: url expected - Assigning null to incompatible properties in QML is deprecated. This will become a compile error in future versions of Qt..*"));
+ QQmlComponent component(ep.get(), testFileUrl("groupFailure.qml"));
+ QScopedPointer<QObject> o(component.create());
+ QVERIFY(!o);
+ ep.reset();
+ // ~QQmlComponent should not crash here
+}
+
// Tests that the implicit import has lowest precedence, in the case where
// there are conflicting types and types only found in the local import.
// Tests that just check one (or the root) type are in ::importsOrder