diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-04-27 16:26:32 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-04-28 07:45:22 +0200 |
commit | 9958edba41ac49097a54e0872c3c4934d2dd81f9 (patch) | |
tree | d6250c1adab075142033febd690c849830bfced9 /tests/auto/corelib/kernel/qobject | |
parent | bd69821074d62a6e8b5eca56d7b9307e1b3e8645 (diff) |
Support move-only functors in invokeMethod and async APIs
Move-only functors must never be passed by value, so fix the
QFunctorSlotObject constructor accordingly.
This then requires adjustments to the various QMetaMethod::invokeMethod
overloads, as those must also perfectly forwad the functor type.
Enable the previously failing test case for move-only functors.
Change-Id: I9c544fd3ddbc5e1da3ca193236291a9f83d86211
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/kernel/qobject')
-rw-r--r-- | tests/auto/corelib/kernel/qobject/tst_qobject.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 9c18a2a0f6..649f075a02 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -8434,6 +8434,7 @@ void tst_QObject::asyncCallbackHelper() static_assert(compiles<AsyncCaller::Prototype0>(&AsyncCaller::callback0)); static_assert(compiles<AsyncCaller::Prototype0>(&AsyncCaller::staticCallback0)); static_assert(compiles<AsyncCaller::Prototype0>(lambda0)); + static_assert(compiles<AsyncCaller::Prototype0>(moveOnlyLambda)); static_assert(compiles<AsyncCaller::Prototype0>(freeFunction0)); static_assert(compiles<AsyncCaller::Prototype0>(functor0)); @@ -8448,6 +8449,7 @@ void tst_QObject::asyncCallbackHelper() static_assert(compiles<AsyncCaller::Prototype1>(&AsyncCaller::callback1)); static_assert(compiles<AsyncCaller::Prototype1>(&AsyncCaller::staticCallback1)); static_assert(compiles<AsyncCaller::Prototype1>(lambda1)); + static_assert(compiles<AsyncCaller::Prototype1>(moveOnlyLambda)); static_assert(compiles<AsyncCaller::Prototype1>(constLambda)); static_assert(compiles<AsyncCaller::Prototype1>(freeFunction1)); static_assert(compiles<AsyncCaller::Prototype1>(functor1)); @@ -8461,11 +8463,6 @@ void tst_QObject::asyncCallbackHelper() static_assert(!compiles<AsyncCaller::Prototype0>(freeFunction1)); static_assert(!compiles<AsyncCaller::Prototype0>(functor1)); - // move-only functor - should work, but doesn't because QFunctorSlotObject requires - // the functor to be of a copyable type! - static_assert(!compiles<AsyncCaller::Prototype0>(moveOnlyLambda)); - static_assert(!compiles<AsyncCaller::Prototype1>(moveOnlyLambda)); - // wrong parameter type static_assert(!compiles<AsyncCaller::Prototype1>(&AsyncCaller::callbackInt)); @@ -8483,7 +8480,7 @@ void tst_QObject::asyncCallbackHelper() QVERIFY(caller.callMe0(&caller, &AsyncCaller::staticCallback0)); QVERIFY(caller.callMe0(&caller, lambda0)); QVERIFY(caller.callMe0(&caller, freeFunction0)); -// QVERIFY(caller.callMe0(&caller, moveOnlyLambda)); + QVERIFY(caller.callMe0(&caller, moveOnlyLambda)); QVERIFY(caller.callMe1(&caller, &AsyncCaller::callback1)); QVERIFY(caller.callMe1(&caller, &AsyncCaller::staticCallback1)); @@ -8495,7 +8492,7 @@ void tst_QObject::asyncCallbackHelper() QVERIFY(caller.callMe0(&AsyncCaller::staticCallback0)); QVERIFY(caller.callMe0(lambda0)); QVERIFY(caller.callMe0(freeFunction0)); -// QVERIFY(caller.callMe0(moveOnlyLambda)); + QVERIFY(caller.callMe0(moveOnlyLambda)); QVERIFY(caller.callMe1(&AsyncCaller::staticCallback1)); QVERIFY(caller.callMe1(lambda1)); |