diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-09 13:23:33 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-06-22 16:05:07 +0200 |
commit | 2c0518eb62ebe475abf84b8ee2fd50c53720d3a4 (patch) | |
tree | 1e729142d25a1452d4be02fd743180ddc22f307e /src/tools/moc/generator.cpp | |
parent | 073214fdf943e1a0beb660a039e39dc1ea43836e (diff) |
moc: Allow reading property values through bindables
The behavior is similar to MEMBER: If the READ accessor is "default",
synthesize it using the bindable.
[ChangeLog][QtCore] You can now specify "READ default" in a Q_PROPERTY
if you also specify a BINDABLE. moc will synthesize a READ accessor in
that case.
Task-number: QTBUG-97249
Change-Id: I4a275adabaed12df95dac505095f847c4be65dfe
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/tools/moc/generator.cpp')
-rw-r--r-- | src/tools/moc/generator.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 9bcddd8670..d03d8513db 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1297,6 +1297,9 @@ void Generator::generateStaticMetacall() else if (cdef->enumDeclarations.value(p.type, false)) fprintf(out, " case %d: *reinterpret_cast<int*>(_v) = QFlag(%s%s()); break;\n", propindex, prefix.constData(), p.read.constData()); + else if (p.read == "default") + fprintf(out, " case %d: *reinterpret_cast< %s*>(_v) = %s%s().value(); break;\n", + propindex, p.type.constData(), prefix.constData(), p.bind.constData()); else if (!p.read.isEmpty()) fprintf(out, " case %d: *reinterpret_cast< %s*>(_v) = %s%s(); break;\n", propindex, p.type.constData(), prefix.constData(), p.read.constData()); |