aboutsummaryrefslogtreecommitdiffstats
path: root/tools/qmltc/prototype/codegenerator.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-01-13 16:18:22 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-01-18 15:27:24 +0000
commit116201361543983686d1e7bc42efbee84518a13b (patch)
treee8c70c6534a989abbf28fa8eda5257a2577ce1d1 /tools/qmltc/prototype/codegenerator.cpp
parente53b255b67c4ef4674d3e8b18617956c979bde4b (diff)
qmltc: Do not generate bindables and setters for QQmlListProperty
Assigning to a QQmlListProperty does not do what you think it does. Change-Id: Ie6ac3208d552d8f40d9f2f4d7fb33c1cd64e4b79 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> (cherry picked from commit 134f305b7f96e1a127261bbfac9bdb1f3a22e546) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tools/qmltc/prototype/codegenerator.cpp')
-rw-r--r--tools/qmltc/prototype/codegenerator.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/tools/qmltc/prototype/codegenerator.cpp b/tools/qmltc/prototype/codegenerator.cpp
index 747db452e9..f60c8b71f9 100644
--- a/tools/qmltc/prototype/codegenerator.cpp
+++ b/tools/qmltc/prototype/codegenerator.cpp
@@ -869,7 +869,9 @@ void CodeGenerator::compileProperty(QQmlJSAotObject &current, const QQmlJSMetaPr
Qml2CppPropertyData compilationData(p);
// 1. add setter and getter
- if (p.isWritable()) {
+ // If p.isList(), it's a QQmlListProperty. Then you can write the underlying list through
+ // the QQmlListProperty object retrieved with the getter. Setting it would make no sense.
+ if (p.isWritable() && !p.isList()) {
QQmlJSAotMethod setter {};
setter.returnType = u"void"_qs;
setter.name = compilationData.write;
@@ -890,13 +892,15 @@ void CodeGenerator::compileProperty(QQmlJSAotObject &current, const QQmlJSMetaPr
mocPieces << u"READ"_qs << getter.name;
// 2. add bindable
- QQmlJSAotMethod bindable {};
- bindable.returnType = u"QBindable<" + underlyingType + u">";
- bindable.name = compilationData.bindable;
- bindable.body << u"return QBindable<" + underlyingType + u">(std::addressof(" + variableName
- + u"));";
- current.functions.emplaceBack(bindable);
- mocPieces << u"BINDABLE"_qs << bindable.name;
+ if (!p.isList()) {
+ QQmlJSAotMethod bindable {};
+ bindable.returnType = u"QBindable<" + underlyingType + u">";
+ bindable.name = compilationData.bindable;
+ bindable.body << u"return QBindable<" + underlyingType + u">(std::addressof(" + variableName
+ + u"));";
+ current.functions.emplaceBack(bindable);
+ mocPieces << u"BINDABLE"_qs << bindable.name;
+ }
// 3. add/check notify (actually, this is already done inside QmltcVisitor)