From 078e967ab29c2bccc7a4c6d25c84a667d91a3d0c Mon Sep 17 00:00:00 2001 From: Valentin Batz Date: Sat, 26 Aug 2023 00:36:47 +0200 Subject: [PATCH] qt library: Make Q_PROPERTY a variadic macro to avoid preprocessorErrorDirective (#5370) Treat Q_PROPERTY as variadic macro to avoid preprocessorErrorDirective with associative container templates itroducing a "," like for example `QHash`. Using templates is totally fine in the context of a moc compiler. The macro Q_PROPERTY is defined as variadic in qobjectdefs.h/qtmetaobject.h when not compiling using the moc compiler. See following references: * For Qt 5.15 https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/kernel/qobjectdefs.h?h=5.15#n104 * For Qt 6.6 https://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/kernel/qtmetamacros.h?h=6.6#n5 --- cfg/qt.cfg | 3 ++- test/cfg/qt.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cfg/qt.cfg b/cfg/qt.cfg index cae153acf..e78a66533 100644 --- a/cfg/qt.cfg +++ b/cfg/qt.cfg @@ -5084,7 +5084,8 @@ - + + diff --git a/test/cfg/qt.cpp b/test/cfg/qt.cpp index 584d1015a..73650f09c 100644 --- a/test/cfg/qt.cpp +++ b/test/cfg/qt.cpp @@ -573,4 +573,10 @@ namespace { // simplifyQtSignalsSlots2 namespace Foo { class Bar; } class Foo::Bar : public QObject { private slots: }; + + // Q_PROPERTY with templates inducing a ',' should not produce a preprocessorErrorDirective + class AssocProperty : public QObject { + public: + Q_PROPERTY(QHash hash READ hash WRITE setHash) + }; }