Respect expected return type in QSlotObject helper

When making asynchronous functions, then the return type is not ever
going to be anything but void, but this makes this helper symmetrical
with QObject::connect logic, where we can then use it to simplify
the code.

Change-Id: I9e1b8bfffb726bb3d6d7282c87e07dc7e9ede5d1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Volker Hilsheimer 2023-04-30 00:41:40 +02:00
parent 60655cbbbb
commit 2cd2789a40

View File

@ -504,6 +504,7 @@ namespace QtPrivate {
makeSlotObject(Functor func)
{
using ExpectedSignature = QtPrivate::FunctionPointer<Prototype>;
using ExpectedReturnType = typename ExpectedSignature::ReturnType;
using ExpectedArguments = typename ExpectedSignature::Arguments;
using ActualSignature = QtPrivate::FunctionPointer<Functor>;
@ -512,12 +513,11 @@ namespace QtPrivate {
if constexpr (QtPrivate::FunctionPointer<Functor>::IsPointerToMemberFunction) {
using ActualArguments = typename ActualSignature::Arguments;
return new QtPrivate::QSlotObject<Functor, ActualArguments, void>(std::move(func));
return new QtPrivate::QSlotObject<Functor, ActualArguments, ExpectedReturnType>(std::move(func));
} else {
constexpr int MatchingArgumentCount = QtPrivate::countMatchingArguments<Prototype, Functor>();
using ActualArguments = typename QtPrivate::List_Left<ExpectedArguments, MatchingArgumentCount>::Value;
return new QtPrivate::QFunctorSlotObject<Functor, ActualArguments, void>(std::move(func));
return new QtPrivate::QFunctorSlotObject<Functor, ActualArguments, ExpectedReturnType>(std::move(func));
}
}