diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-09-08 16:48:06 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-09-18 12:45:07 +0200 |
commit | d3f60addaad4da067bb870ff2da533a33eb8f6eb (patch) | |
tree | 0b5b7b9db0bcdaa7f06cd8fd5c21f4fa7f1e114b | |
parent | 58b1d29fef5c086fe2c619e26ffb75cdc860a31c (diff) |
qmllint: Do not complain about writing to list properties
List properties cannot be read-only.
Fixes: QTBUG-114144
Change-Id: Icaf69f581cfb5cdbb75e9b319fcb27b477f241b0
Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
(cherry picked from commit dfa51fe0bcc4dafac454791e24e6bb4b919438d7)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit ae018e9a66fa4cab5e5c4ed027b1090488ff7f13)
-rw-r--r-- | src/qmlcompiler/qqmljstypepropagator.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/data/writeListProperty.qml | 7 | ||||
-rw-r--r-- | tests/auto/qml/qmllint/tst_qmllint.cpp | 1 |
3 files changed, 9 insertions, 1 deletions
diff --git a/src/qmlcompiler/qqmljstypepropagator.cpp b/src/qmlcompiler/qqmljstypepropagator.cpp index a61a6e5743..24bc75c0dc 100644 --- a/src/qmlcompiler/qqmljstypepropagator.cpp +++ b/src/qmlcompiler/qqmljstypepropagator.cpp @@ -899,7 +899,7 @@ void QQmlJSTypePropagator::generate_StoreProperty(int nameIndex, int base) return; } - if (!property.isWritable()) { + if (!property.isWritable() && !property.storedType()->isListProperty()) { setError(u"Can't assign to read-only property %1"_s.arg(propertyName)); m_logger->log(u"Cannot assign to read-only property %1"_s.arg(propertyName), diff --git a/tests/auto/qml/qmllint/data/writeListProperty.qml b/tests/auto/qml/qmllint/data/writeListProperty.qml new file mode 100644 index 0000000000..8015fdf51b --- /dev/null +++ b/tests/auto/qml/qmllint/data/writeListProperty.qml @@ -0,0 +1,7 @@ +import QtQuick + +Item { + id: self + property Item a: Item { id: a } + Component.onCompleted: self.data = [ a ] +} diff --git a/tests/auto/qml/qmllint/tst_qmllint.cpp b/tests/auto/qml/qmllint/tst_qmllint.cpp index daccda852a..44747434fb 100644 --- a/tests/auto/qml/qmllint/tst_qmllint.cpp +++ b/tests/auto/qml/qmllint/tst_qmllint.cpp @@ -1246,6 +1246,7 @@ void TestQmllint::cleanQmlCode_data() QTest::newRow("attachedImportUse") << QStringLiteral("attachedImportUse.qml"); QTest::newRow("VariantMapGetPropertyLookup") << QStringLiteral("variantMapLookup.qml"); QTest::newRow("ScriptInTemplate") << QStringLiteral("scriptInTemplate.qml"); + QTest::newRow("WriteListProperty") << QStringLiteral("writeListProperty.qml"); } void TestQmllint::cleanQmlCode() |