From b49327145eb984c2051585d89f0826c58d35c116 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 29 Aug 2013 12:53:18 +0200 Subject: QMetaMethod::invoke: compare the QMetaType id of the return types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests/auto/corelib/kernel') 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 sl13(QList l1); + qint64 sl14(); void testSender(); void testReference(QString &str); @@ -395,6 +396,9 @@ const char *QtTestObject::sl12() { slotResult = "sl12"; return "foo"; } QList QtTestObject::sl13(QList 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")); -- cgit v1.2.3