funchelpers: Add a way to invoke a callable with a list of arguments
authorManuel Nickschas <sputnick@quassel-irc.org>
Mon, 15 Oct 2018 22:39:31 +0000 (00:39 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sun, 18 Nov 2018 10:06:43 +0000 (11:06 +0100)
In various places, we serialize function arguments as a QVariantList,
and later use QMetaMethod and friends to call a slot with that list.

In order to avoid this kind of runtime method lookup, we need a way
to directly invoke a given callable (e.g. a function pointer) with
a list of serialized arguments. We'll also want to use the type-based
conversion functionality of QVariant instead of using undocumented
methods and reinterpret_cast'ing raw memory, as is currently the case.

Provide a method invokeWithArgsList() that takes any callable and
a list of arguments serialized in a QVariantList, performs some
runtime sanity checks (argument count and types), and invokes the
callable with the arguments converted to the correct type, if
possible.

Also add a test case for this function.


No differences found