diff options
| author | Sami Shalayel <sami.shalayel@qt.io> | 2025-06-05 10:51:46 +0200 |
|---|---|---|
| committer | Sami Shalayel <sami.shalayel@qt.io> | 2025-06-06 13:04:40 +0200 |
| commit | c9713681e8d0ee7b7a69d38c5972ee73e8ee4b78 (patch) | |
| tree | 24324285d457bdea2b780b3faa0c8d73ff63125b /src/qmlcompiler/qqmljsimportvisitor.cpp | |
| parent | f2e8a9b49f2c1bd8d1dc6bc424d6148173f9a142 (diff) | |
qmlcachegen: fix crash on unresolved type with required property
qmlcachegen can't resolve all types when importing QtQuick.Controls, so
scopes from QtQuick.Controls might be unresolved.
Check the scope before creating a fix suggesion when checking the
required properties, and add a test that tests a file with required
properties on an unresolved base type "Tumbler".
This also fixes the crashes from QTBUG-137196 and QTBUG-136998 it seems.
Pick-to: 6.10 6.9 6.8 6.5
Fixes: QTBUG-137411
Fixes: QTBUG-137196
Fixes: QTBUG-136998
Change-Id: Ibf461b54abf84ba13bff8c4833940c7359cf2d8e
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsimportvisitor.cpp')
| -rw-r--r-- | src/qmlcompiler/qqmljsimportvisitor.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/qmlcompiler/qqmljsimportvisitor.cpp b/src/qmlcompiler/qqmljsimportvisitor.cpp index 5e3db1b2bd..b55dbb4d60 100644 --- a/src/qmlcompiler/qqmljsimportvisitor.cpp +++ b/src/qmlcompiler/qqmljsimportvisitor.cpp @@ -1055,16 +1055,17 @@ void QQmlJSImportVisitor::checkRequiredProperties() : u"here"_s; if (!prevRequiredScope.isNull()) { - auto sourceScope = prevRequiredScope->baseType(); - suggestion = QQmlJSFixSuggestion{ - "%1:%2:%3: Property marked as required in %4."_L1 - .arg(sourceScope->filePath()) - .arg(sourceScope->sourceLocation().startLine) - .arg(sourceScope->sourceLocation().startColumn) - .arg(requiredScopeName), - sourceScope->sourceLocation() - }; - suggestion->setFilename(sourceScope->filePath()); + if (auto sourceScope = prevRequiredScope->baseType()) { + suggestion = QQmlJSFixSuggestion{ + "%1:%2:%3: Property marked as required in %4."_L1 + .arg(sourceScope->filePath()) + .arg(sourceScope->sourceLocation().startLine) + .arg(sourceScope->sourceLocation().startColumn) + .arg(requiredScopeName), + sourceScope->sourceLocation() + }; + suggestion->setFilename(sourceScope->filePath()); + } } else { message += " (marked as required by %1)"_L1.arg(requiredScopeName); } |
