aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2024-02-19 18:37:32 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2024-02-20 22:46:15 +0000
commit3880a8902f140464bb3ccf55f77175d890bb4e0b (patch)
treefa88b89facc6a77fb34bc5aea77c3bf92207be5d
parentba0ebf06daae057a54cd5b89fe0b37787b84bd63 (diff)
qmllint: Restrict attached property validators to simple cases
There is no API to propagate grouped and attached properties in a structured form, yet. Therefore we cannot properly analyze generalized grouped properties, yet. Pick-to: 6.5 Fixes: QTBUG-120526 Change-Id: I4c39536aea41469a1de04c5b588059960105dcde Reviewed-by: Semih Yavuz <semih.yavuz@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> (cherry picked from commit 80d937e9e037d4e7998c114b4174fda6b47f39b1) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 5b113ad16aef379c8dae990cf217daa36fcef175)
-rw-r--r--src/plugins/qmllint/quick/quicklintplugin.cpp11
-rw-r--r--tests/auto/qml/qmllint/data/groupedAttachedLayout.qml20
-rw-r--r--tests/auto/qml/qmllint/tst_qmllint.cpp1
3 files changed, 29 insertions, 3 deletions
diff --git a/src/plugins/qmllint/quick/quicklintplugin.cpp b/src/plugins/qmllint/quick/quicklintplugin.cpp
index c55e8356b8..b3e6525884 100644
--- a/src/plugins/qmllint/quick/quicklintplugin.cpp
+++ b/src/plugins/qmllint/quick/quicklintplugin.cpp
@@ -134,11 +134,16 @@ void AttachedPropertyTypeValidatorPass::onBinding(const QQmlSA::Element &element
const QQmlSA::Element &bindingScope,
const QQmlSA::Element &value)
{
- Q_UNUSED(element)
- Q_UNUSED(propertyName)
- Q_UNUSED(bindingScope)
Q_UNUSED(value)
+ // We can only analyze simple attached bindings since we don't see
+ // the grouped and attached properties that lead up to this here.
+ //
+ // TODO: This is very crude.
+ // We should add API for grouped and attached properties.
+ if (propertyName.count(QLatin1Char('.')) > 1)
+ return;
+
checkWarnings(bindingScope.baseType(), element, binding.sourceLocation());
}
diff --git a/tests/auto/qml/qmllint/data/groupedAttachedLayout.qml b/tests/auto/qml/qmllint/data/groupedAttachedLayout.qml
new file mode 100644
index 0000000000..7cfe98d4f8
--- /dev/null
+++ b/tests/auto/qml/qmllint/data/groupedAttachedLayout.qml
@@ -0,0 +1,20 @@
+import QtQuick
+import QtQuick.Layouts
+
+Window {
+ id: root
+
+ Rectangle {
+ id: redRect
+ }
+
+ Item {
+ states: [
+ State {
+ PropertyChanges {
+ redRect.Layout.fillWidth: true
+ }
+ }
+ ]
+ }
+}
diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp
index 1494d4aee6..d15277d6b6 100644
--- a/tests/auto/qml/qmllint/tst_qmllint.cpp
+++ b/tests/auto/qml/qmllint/tst_qmllint.cpp
@@ -1282,6 +1282,7 @@ void TestQmllint::cleanQmlCode_data()
QTest::newRow("AddressableValue") << QStringLiteral("addressableValue.qml");
QTest::newRow("WriteListProperty") << QStringLiteral("writeListProperty.qml");
QTest::newRow("dontConfuseMemberPrintWithGlobalPrint") << QStringLiteral("findMemberPrint.qml");
+ QTest::newRow("groupedAttachedLayout") << QStringLiteral("groupedAttachedLayout.qml");
}
void TestQmllint::cleanQmlCode()