summaryrefslogtreecommitdiffstats
path: root/tests/auto/moc
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-02-24 11:38:56 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2011-02-24 11:46:41 (GMT)
commitf57dac1faf4d39eae851d0e9238a8b5968b48a73 (patch)
tree9bb4982a412e48f823c64708b3ceb311ff9bae62 /tests/auto/moc
parent62d78d36c49a3e108bd24ef831d76ff2c4a9ba65 (diff)
downloadQt-f57dac1faf4d39eae851d0e9238a8b5968b48a73.zip
Qt-f57dac1faf4d39eae851d0e9238a8b5968b48a73.tar.gz
Qt-f57dac1faf4d39eae851d0e9238a8b5968b48a73.tar.bz2
Fix Q_INVOKABLE declared after Q_PROPERTY
moc was starting to parse function one token too late. This was usually unnoticed because there is usually a semi colon, or a colon, or some other token that are ignored. But in this case, a Q_PROPERTY is not ignored, the parsing would fail. Reviewed-by: brad
Diffstat (limited to 'tests/auto/moc')
-rw-r--r--tests/auto/moc/tst_moc.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp
index 3e15bde..1d78633 100644
--- a/tests/auto/moc/tst_moc.cpp
+++ b/tests/auto/moc/tst_moc.cpp
@@ -493,6 +493,7 @@ private slots:
void QTBUG5590_dummyProperty();
void QTBUG12260_defaultTemplate();
void notifyError();
+ void QTBUG17635_invokableAndProperty();
signals:
void sigWithUnsignedArg(unsigned foo);
void sigWithSignedArg(signed foo);
@@ -1384,6 +1385,30 @@ void tst_Moc::notifyError()
#endif
}
+class QTBUG_17635_InvokableAndProperty : public QObject
+{
+ Q_OBJECT
+public:
+ Q_PROPERTY(int numberOfEggs READ numberOfEggs)
+ Q_PROPERTY(int numberOfChickens READ numberOfChickens)
+ Q_INVOKABLE QString getEgg(int index) { return QString::fromLatin1("Egg"); }
+ Q_INVOKABLE QString getChicken(int index) { return QString::fromLatin1("Chicken"); }
+ int numberOfEggs() { return 2; }
+ int numberOfChickens() { return 4; }
+};
+
+void tst_Moc::QTBUG17635_invokableAndProperty()
+{
+ //Moc used to fail parsing Q_INVOKABLE if they were dirrectly following a Q_PROPERTY;
+ QTBUG_17635_InvokableAndProperty mc;
+ QString val;
+ QMetaObject::invokeMethod(&mc, "getEgg", Q_RETURN_ARG(QString, val), Q_ARG(int, 10));
+ QCOMPARE(val, QString::fromLatin1("Egg"));
+ QMetaObject::invokeMethod(&mc, "getChicken", Q_RETURN_ARG(QString, val), Q_ARG(int, 10));
+ QCOMPARE(val, QString::fromLatin1("Chicken"));
+ QVERIFY(mc.metaObject()->indexOfProperty("numberOfEggs") != -1);
+ QVERIFY(mc.metaObject()->indexOfProperty("numberOfChickens") != -1);
+}
QTEST_APPLESS_MAIN(tst_Moc)
#include "tst_moc.moc"