invokeMethod: Try invoking functor and member function accepting pointer, returning void
Due to the pre-existing overload of invokeMethod that accepts a void-pointer there is concern that the new overloads would not be preferred. Here we add a test for this to verify all supported platforms work. Change-Id: Ie5ac7bf16643599006ac57e0145feb6aace3fa87 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
a7d2855b3c
commit
4ffb227c78
@ -516,6 +516,8 @@ public slots:
|
||||
qlonglong *sl15(qlonglong *);
|
||||
MyForwardDeclaredType *sl16(MyForwardDeclaredType *);
|
||||
|
||||
void sl17(int *i) { *i = 242; }
|
||||
|
||||
void overloadedSlot();
|
||||
void overloadedSlot(int, int);
|
||||
void overloadedSlot(int);
|
||||
@ -1175,6 +1177,24 @@ void tst_QMetaObject::invokePointer()
|
||||
QVERIFY(QMetaObject::invokeMethod(&obj, variadic, qReturnArg(result), u"bu"_s, 1, 2, 3, 4, 5, 6));
|
||||
QCOMPARE(result, u"bu123456");
|
||||
}
|
||||
{
|
||||
// Testing a functor returning void and accepting a pointer,
|
||||
// this may trigger the pointer to be interpreted as the old void*
|
||||
// return parameter.
|
||||
bool invoked = false;
|
||||
auto lambda = [&invoked](void *ptr) -> void {
|
||||
Q_UNUSED(ptr);
|
||||
invoked = true;
|
||||
};
|
||||
int i = 242;
|
||||
QVERIFY(QMetaObject::invokeMethod(&obj, lambda, &i));
|
||||
QVERIFY(invoked);
|
||||
|
||||
// member fn
|
||||
i = 0;
|
||||
QVERIFY(QMetaObject::invokeMethod(&obj, &QtTestObject::sl17, &i));
|
||||
QCOMPARE(i, 242);
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QMetaObject::invokeQueuedMetaMember()
|
||||
|
Loading…
Reference in New Issue
Block a user