diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-01-13 16:18:22 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-01-18 15:27:24 +0000 |
commit | 116201361543983686d1e7bc42efbee84518a13b (patch) | |
tree | e8c70c6534a989abbf28fa8eda5257a2577ce1d1 /tools/qmltc | |
parent | e53b255b67c4ef4674d3e8b18617956c979bde4b (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')
-rw-r--r-- | tools/qmltc/prototype/codegenerator.cpp | 20 | ||||
-rw-r--r-- | tools/qmltc/prototype/qml2cppdefaultpasses.cpp | 4 |
2 files changed, 14 insertions, 10 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 ¤t, 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 ¤t, 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) diff --git a/tools/qmltc/prototype/qml2cppdefaultpasses.cpp b/tools/qmltc/prototype/qml2cppdefaultpasses.cpp index aa50766820..bbf462b8f6 100644 --- a/tools/qmltc/prototype/qml2cppdefaultpasses.cpp +++ b/tools/qmltc/prototype/qml2cppdefaultpasses.cpp @@ -560,9 +560,9 @@ static void setupQmlCppType(const Qml2CppContext &context, const QQmlJSScope::Pt Qml2CppPropertyData compiledData(p); if (p.read().isEmpty()) p.setRead(compiledData.read); - if (p.write().isEmpty() && p.isWritable()) + if (p.write().isEmpty() && p.isWritable() && !p.isList()) p.setWrite(compiledData.write); - if (p.bindable().isEmpty()) + if (p.bindable().isEmpty() && !p.isList()) p.setBindable(compiledData.bindable); // TODO: p.setNotify(compiledData.notify); - ? type->addOwnProperty(p); |