[Development] QMetaType support for QFuture

Arno Rehn a.rehn at menlosystems.com
Fri May 7 18:27:54 CEST 2021


Hi Sona,

On 07.05.21 17:11, Sona Kurazyan wrote:
> You could use the QFutureInterfaceBase (non-templated) class directly
> to build a type-erased future, that's basically what QFuture is using
> underneath. Although it's internal (not documented and is considered
> to be private), but it's declared in a public header
> (qfutureinterface.h) and you can still use it. QFutureInterfaceBase's
> methods for accessing its internals are public (with a few exceptions
> that you probably won't need to use). I hope that helps.

Yep, that's what I thought as well. But I cannot get it from an existing 
QFuture because it's a private member. We could add some private API to 
extract the QFutureInterfaceBase, however.

Anyway, I think I'll have to add some QMetaType magic anyway for this to 
work. In QtWebChannel, we get the method return value wrapped in a 
QVariant, so the QFuture<T> is wrapped in a QVariant. From there, I 
cannot extract the QFutureInterfaceBase in any way.

I *could* just memcpy from QVariant's data pointer to a 
QFutureInterfaceBase*, but I'm pretty sure that this is UB.

Any pointer where to start?

Regards,
Arno

-- 
Arno Rehn
Tel +49 89 189 166 0
Fax +49 89 189 166 111
a.rehn at menlosystems.com
www.menlosystems.com

Menlo Systems GmbH
Bunsenstrasse 5, D-82152 Martinsried, Germany
Amtsgericht München HRB 138145
Geschäftsführung: Dr. Michael Mei, Dr. Ronald Holzwarth
USt.-IdNr. DE217772017, St.-Nr. 14316170324


More information about the Development mailing list