aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2020-05-06 13:21:21 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2020-05-06 13:58:08 +0200
commit45537009a8a3f8e855c1adf0208084849b6dc9c4 (patch)
treee1b30dfb0118875bb57be53e3b15348795dfd35c
parentaa470fa92d8139ea849c00e01db5ffc537fe6981 (diff)
Fix qmllint crash
Fixes: QTBUG-83915 Change-Id: I26731ebcec6be46602b6acc7562c65b1c9f3e43a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r--tests/auto/qml/qmllint/data/crashConnections.qml5
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp4
-rw-r--r--tools/qmllint/findwarnings.cpp2
3 files changed, 10 insertions, 1 deletions
diff --git a/tests/auto/qml/qmllint/data/crashConnections.qml b/tests/auto/qml/qmllint/data/crashConnections.qml
new file mode 100644
index 0000000000..cac50c84bd
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/crashConnections.qml
@@ -0,0 +1,5 @@
+import QtQuick 2.0
+
+Connections {
+ target: FirstRunDialog
+} \ No newline at end of file
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 0f6fac4ddf..bdb5cf37c0 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -107,6 +107,10 @@ void TestQmllint::testUnqualified_data()
QTest::newRow("CatchStatement") << QStringLiteral("CatchStatement.qml") << QStringLiteral("err") << 6 << 21;
QTest::newRow("NonSpuriousParent") << QStringLiteral("nonSpuriousParentWarning.qml") << QStringLiteral("property int x: <id>.parent.x") << 6 << 25;
+
+ QTest::newRow("crashConnections")
+ << QStringLiteral("crashConnections.qml")
+ << QStringLiteral("target: FirstRunDialog") << 4 << 13;
}
void TestQmllint::testUnknownCausesFail()
diff --git a/tools/qmllint/findwarnings.cpp b/tools/qmllint/findwarnings.cpp
index 25a4975468..cecbf838d7 100644
--- a/tools/qmllint/findwarnings.cpp
+++ b/tools/qmllint/findwarnings.cpp
@@ -731,7 +731,7 @@ bool FindWarningVisitor::check()
// now that all ids are known, revisit any Connections whose target were perviously unknown
for (auto const &outstandingConnection: m_outstandingConnections) {
auto targetScope = m_qmlid2scope[outstandingConnection.targetName];
- if (outstandingConnection.scope)
+ if (outstandingConnection.scope && targetScope != nullptr)
outstandingConnection.scope->addMethods(targetScope->methods());
QScopedValueRollback<ScopeTree::Ptr> rollback(m_currentScope, outstandingConnection.scope);
outstandingConnection.uiod->initializer->accept(this);