[Development] invokeMethod() with function pointers

Benjamin TERRIER b.terrier at gmail.com
Tue Jan 24 12:34:01 CET 2017


Hi,

I'd like to get this in before 5.9 FF.

The current state is:
 - It works for member functions, function pointers and functors
 - It soft breaks existing code that were passing null literals.
 - The new functions do not accepts any arguments, users have to use lambda
 - The new functions do accept an optional return argument in the form
"ReturnType *" (without using Q_ARG),
the type is checked during compilation for function pointers (member or
not) using QtPrivate::FunctionPointer.
I am not sure for functors though as QtPrivate::FunctionPointer does not
work in this case, but QFunctorSlotObject
ensure that the actual return type of the functor can be assigned to a
ReturnType.

What must be done:
 - Add documentation
 - Complete auto tests
 - Optionally, remove the "ReturnType *" argument and for users to use
lambda with capture.
This remove the need to check for return in case of queued connection, but
add the responsibility for the user to ensure the lifespace
of variable captured by reference to sill be valid when the lambda is
executed.
- Optionally, move the function pointer/lambda to the last argument
position. This can make nicer code when using lambda,
at the cost of having to provide more overloads instead of using optional
arguments.

I would appreciate if any of you could check the gerrit change (
https://codereview.qt-project.org/#/c/182339/) and provide feedbacks,
especially if there is anything that would require a major change of the
current state.

Also, I'd like to get more opinions about the 2 optional changes.

Thanks.

Regards,

Benjamin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170124/f828695f/attachment.html>


More information about the Development mailing list