moc: fix Q_PROPERTY with parentheses in their MEMBER clause

This was never a documented feature, but happended to work before Qt 5.5.
It broke because the peoperty access went into the static function and are
now prefixed with '_t->'

So restore the behavior as it was by not including the parentheses in the
member name.

Task-number: QTBUG-47695
Change-Id: Ic3509ddea7ac9abc871e71f5bfbe81d04d08e9bc
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
bb10
Olivier Goffart 2015-10-21 22:47:10 +02:00 committed by Olivier Goffart (Woboq GmbH)
parent f57afda69f
commit d206d04b7c
2 changed files with 14 additions and 0 deletions

View File

@ -1060,6 +1060,7 @@ void Moc::createPropertyDef(PropertyDef &propDef)
QByteArray v, v2;
if (test(LPAREN)) {
v = lexemUntil(RPAREN);
v = v.mid(1, v.length() - 2); // removes the '(' and ')'
} else if (test(INTEGER_LITERAL)) {
v = lexem();
if (l != "REVISION")

View File

@ -513,6 +513,8 @@ class tst_Moc : public QObject
Q_PROPERTY(QString member4 MEMBER sMember NOTIFY member4Changed)
Q_PROPERTY(QString member5 MEMBER sMember NOTIFY member5Changed)
Q_PROPERTY(QString member6 MEMBER sConst CONSTANT)
Q_PROPERTY(QString sub1 MEMBER (sub.m_string))
Q_PROPERTY(QString sub2 READ (sub.string) WRITE (sub.setString))
public:
inline tst_Moc() : sConst("const") {}
@ -626,6 +628,13 @@ private:
QString sMember;
const QString sConst;
PrivatePropertyTest *pPPTest;
struct {
QString m_string;
void setString(const QString &s) { m_string = s; }
QString string() { return m_string; }
} sub;
};
void tst_Moc::initTestCase()
@ -2044,6 +2053,10 @@ void tst_Moc::memberProperties_data()
<< 1 << "blub5" << "blub5Changed(const QString&)" << "mno" << true << "mno";
QTest::newRow("private MEMBER property with CONSTANT")
<< 1 << "blub6" << "" << "test" << false << "const";
QTest::newRow("sub1")
<< 0 << "sub1" << "" << "helloSub1" << true << "helloSub1";
QTest::newRow("sub2")
<< 0 << "sub2" << "" << "helloSub2" << true << "helloSub2";
}
void tst_Moc::memberProperties()