From 6fc328ce1d19ba1a3754367d66a2ea4ac9774bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Thu, 27 Jun 2024 12:40:26 +0200 Subject: [PATCH] wobjectimpl.h: update FunctorCall for Qt 6.8+ The "ApplyReturnValue" struct has been removed in https://github.com/qt/qtbase/commit/f894f04c9d03878116de61c11d4591da67c10378 ; this updates the code with the new pattern --- src/wobjectimpl.h | 54 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/wobjectimpl.h b/src/wobjectimpl.h index 5e32ff2..76c721b 100644 --- a/src/wobjectimpl.h +++ b/src/wobjectimpl.h @@ -1026,7 +1026,7 @@ inline auto propReset(F f, O *o) W_RETURN(((o->*f)(),0)) template inline void propReset(T...) {} -#if QT_VERSION >= QT_VERSION_CHECK(6,3,0) +#if QT_VERSION >= QT_VERSION_CHECK(6,3,0) && QT_VERSION < QT_VERSION_CHECK(6, 8, 0) // note: Qt 6.3 introduced a check here that allows only QObjects - but we need it for Gadgets as well template struct FunctorCall; template @@ -1063,6 +1063,58 @@ struct FunctorCall, QtPrivate::List, R (o->*f)((*reinterpret_cast::Type *>(arg[II+1]))...), QtPrivate::ApplyReturnValue(arg[0]); } }; +#elif QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) +template struct FunctorCall; +template +struct FunctorCall, QtPrivate::List, R, Function> : QtPrivate::FunctorCallBase { + static void call(Function f, void **arg) + { + using namespace QtPrivate; + call_internal(arg, [&] { + return f((*reinterpret_cast::Type *>(arg[II+1]))...); + }); + } +}; +template +struct FunctorCall, QtPrivate::List, R, SlotRet (Obj::*)(SlotArgs...)> : QtPrivate::FunctorCallBase { + static void call(SlotRet (Obj::*f)(SlotArgs...), Obj *o, void **arg) + { + using namespace QtPrivate; + call_internal(arg, [&] { + return (o->*f)((*reinterpret_cast::Type *>(arg[II+1]))...); + }); + } +}; +template +struct FunctorCall, QtPrivate::List, R, SlotRet (Obj::*)(SlotArgs...) const> : QtPrivate::FunctorCallBase { + static void call(SlotRet (Obj::*f)(SlotArgs...) const, Obj *o, void **arg) + { + using namespace QtPrivate; + call_internal(arg, [&] { + return (o->*f)((*reinterpret_cast::Type *>(arg[II+1]))...); + }); + } +}; +template +struct FunctorCall, QtPrivate::List, R, SlotRet (Obj::*)(SlotArgs...) noexcept> : QtPrivate::FunctorCallBase { + static void call(SlotRet (Obj::*f)(SlotArgs...) noexcept, Obj *o, void **arg) + { + using namespace QtPrivate; + call_internal(arg, [&]() noexcept { + return (o->*f)((*reinterpret_cast::Type *>(arg[II+1]))...); + }); + } +}; +template +struct FunctorCall, QtPrivate::List, R, SlotRet (Obj::*)(SlotArgs...) const noexcept> : QtPrivate::FunctorCallBase { + static void call(SlotRet (Obj::*f)(SlotArgs...) const noexcept, Obj *o, void **arg) + { + using namespace QtPrivate; + call_internal(arg, [&]() noexcept { + return (o->*f)((*reinterpret_cast::Type *>(arg[II+1]))...); + }); + } +}; #endif struct FriendHelper {