summaryrefslogtreecommitdiffstats
path: root/src/tools/moc/moc.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-07-07 16:54:44 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-07-08 11:01:38 +0200
commit0cd3820e4d62d91c006a807f04c77166b2dbc7f5 (patch)
treec2045a95f28b40dd2196f26637b57d330ffbbfb6 /src/tools/moc/moc.cpp
parenteacf83594a5bf063665fdecc6c438673dc9f2cf6 (diff)
moc: Allow out-of-line storage for Q_PRIVATE_QPROPERTY
If you pass "STORED false" the name is interpreted as function to be invoked in order to access the property. This allows storage of a property in a lazily allocated data type. Change-Id: I4d3a9cac6985c6419ce687868cb74b91921595a6 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/tools/moc/moc.cpp')
-rw-r--r--src/tools/moc/moc.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp
index e31bdfbb15..44e669a664 100644
--- a/src/tools/moc/moc.cpp
+++ b/src/tools/moc/moc.cpp
@@ -1527,14 +1527,9 @@ void Moc::parsePrivateQProperty(ClassDef *def)
next(IDENTIFIER);
const QByteArray setter = lexem();
- def->privateQProperties += PrivateQPropertyDef{type, name, setter, accessor};
-
PropertyDef propDef;
propDef.name = name;
- propDef.qpropertyname = name;
propDef.type = type.name;
- propDef.read = name + ".value";
- propDef.write = name + ".setValue";
propDef.isQProperty = true;
propDef.isQPropertyWithNotifier = true;
propDef.inPrivateClass = accessor;
@@ -1544,6 +1539,17 @@ void Moc::parsePrivateQProperty(ClassDef *def)
if (test(COMMA))
parsePropertyAttributes(propDef);
+ propDef.qpropertyname = (propDef.stored == "true") ? name : (name + "()");
+
+ def->privateQProperties += PrivateQPropertyDef {
+ type, name, setter, accessor, propDef.qpropertyname
+ };
+
+ if (propDef.read.isEmpty())
+ propDef.read = propDef.qpropertyname + ".value";
+ if (propDef.write.isEmpty())
+ propDef.write = propDef.qpropertyname + ".setValue";
+
next(RPAREN);
def->propertyList += propDef;