Details
-
Suggestion
-
Resolution: Won't Do
-
Not Evaluated
-
None
-
6.3.0 Beta1
-
None
Description
I recently used
QtRemoteObjects::copyStoredProperties<T>(src, dst);
with T subclassing QObject.
This leads to an assertion error because copyStoredProperties internally uses QMetaProperty::read/writeOnGadget. Both access methods require PropertyAccessInStaticMetaCall to be set (i.e. only for Q_GADGET).
Nevertheless, readOnGadget/writeOnGadget actually work fine even for QObjects after ignoring the assertion error.
My suggestion is to let readOnGadget and writeOnGadget accept QObjects by extending the assert expression in qmetaobject.cpp with an inheritance check:
Q_ASSERT((priv(mobj->d.data)->flags & PropertyAccessInStaticMetaCall && mobj->d.static_metacall) || mobj->inherits(&QObject::staticMetaObject));
In case, meta object is actually QObject subtype the following phantom cast to QObject pointer is ok:
return read(reinterpret_cast<const QObject*>(gadget));
This change will not have any effect for the default use case of reading and writing Q_GADGETs' properties.