diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2013-08-29 12:53:18 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-29 17:03:41 +0200 |
commit | b49327145eb984c2051585d89f0826c58d35c116 (patch) | |
tree | a1d774dde54deed6659a020021f6cb879fd7eee4 /tests/auto/corelib/kernel | |
parent | e59a5f9fdcec5df2f54e88d75a75fcb4a2fe577b (diff) |
QMetaMethod::invoke: compare the QMetaType id of the return types
Since Qt5, the QMetaObject do not contains the string name of the
builtin types, but only the QMetaType id. QMetaMethod::typeName
convert back from the id to the string. But if the type is aliased,
the string of the main type is returned.
This was the case for example for qint64 which is transformed to
"qlonglong".
This causes a regression in QMetaType::invoke when trying to invoke a
method which return an aliased type, since the string comparison would
fail.
Fix the problem by also comparing the metatype id.
Changelog: QMetaMethod::invoke: Fix return of aliased meta type
Task-number: QTBUG-33222
Change-Id: Iec7b99dcbf7b23eb818de74f413e4451ce510ac4
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
Diffstat (limited to 'tests/auto/corelib/kernel')
-rw-r--r-- | tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp index ca80c8926f..4f1320e375 100644 --- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp @@ -328,6 +328,7 @@ public slots: QObject *sl11(); const char *sl12(); QList<QString> sl13(QList<QString> l1); + qint64 sl14(); void testSender(); void testReference(QString &str); @@ -395,6 +396,9 @@ const char *QtTestObject::sl12() { slotResult = "sl12"; return "foo"; } QList<QString> QtTestObject::sl13(QList<QString> l1) { slotResult = "sl13"; return l1; } +qint64 QtTestObject::sl14() +{ slotResult = "sl14"; return Q_INT64_C(123456789)*123456789; } + void QtTestObject::testReference(QString &str) { slotResult = "testReference:" + str; str = "gotcha"; } @@ -513,6 +517,13 @@ void tst_QMetaObject::invokeMetaMember() QCOMPARE(returnValue, argument); QCOMPARE(obj.slotResult, QString("sl13")); + // return qint64 + qint64 return64; + QVERIFY(QMetaObject::invokeMethod(&obj, "sl14", + Q_RETURN_ARG(qint64, return64))); + QCOMPARE(return64, Q_INT64_C(123456789)*123456789); + QCOMPARE(obj.slotResult, QString("sl14")); + //test signals QVERIFY(QMetaObject::invokeMethod(&obj, "sig0")); QCOMPARE(obj.slotResult, QString("sl0")); |