From 844e4f7b982f2622dbdce0c4b70775d5bd17f043 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Wed, 24 Jun 2020 08:25:17 +0200 Subject: moc: Fix QProperty code generation This addresses two issues: 1. The generated code for QNotifiedProperty was broken when T is a pointer. Notably, const S* & is not a constant reference to S*. This is addressed by consistently using T const& instead of const T&. 2. The Q_PRIVATE_QPROPERTY approach assumed that the property name and the getter are equal. This does break when they are not, and we are unable to change either of them due to API compatibility concerns. An example of this would be QQuickItem's parent property with a parentItem getter. Therefore, we now allow the usage of NAME to override the name of the property. Change-Id: Idf2e85576c74371b5b0f6db15dbe6f2d17c5e33d Reviewed-by: Ulf Hermann --- src/tools/moc/moc.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/tools/moc/moc.cpp') diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 5a1f0afab6..e31bdfbb15 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -1317,6 +1317,12 @@ void Moc::parsePropertyAttributes(PropertyDef &propDef) } else if(l[0] == 'F' && l == "FINAL") { propDef.final = true; continue; + } else if (l[0] == 'N' && l == "NAME") { + if (!propDef.isQProperty) + error(1); + next(IDENTIFIER); + propDef.name = lexem(); + continue; } else if (l[0] == 'R' && l == "REQUIRED") { propDef.required = true; continue; @@ -1525,6 +1531,7 @@ void Moc::parsePrivateQProperty(ClassDef *def) PropertyDef propDef; propDef.name = name; + propDef.qpropertyname = name; propDef.type = type.name; propDef.read = name + ".value"; propDef.write = name + ".setValue"; -- cgit v1.2.3