From 0cd3820e4d62d91c006a807f04c77166b2dbc7f5 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 7 Jul 2020 16:54:44 +0200 Subject: 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 Reviewed-by: Fabian Kosmale --- src/tools/moc/moc.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/tools/moc/moc.cpp') 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; -- cgit v1.2.3