QMetaProperty: remove property auto-registration code

Qt 6 automatically registers all types used in properties. Thus, the
functionality is mostly obsolete since Qt 6. We can simply return the
stored metatype's id instead.
The code in moc is kept in place for compatibility with older code,
though there seem to be no remaining users of the metacall in Qt itself
anymore.

Change-Id: I3c654150988ae7780b4e9ea1f16191fdadf8d791
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
bb10
Fabian Kosmale 2022-02-05 22:59:17 +01:00
parent 0af3d57980
commit 0477c78a04
3 changed files with 9 additions and 4 deletions

View File

@ -3160,19 +3160,20 @@ bool QMetaProperty::isAlias() const
return (data.flags() & Alias);
}
#if QT_DEPRECATED_SINCE(6, 4)
/*!
\internal
Historically:
Executes metacall with QMetaObject::RegisterPropertyMetaType flag.
Returns id of registered type or QMetaType::UnknownType if a type
could not be registered for any reason.
Obsolete since Qt 6
*/
int QMetaProperty::registerPropertyType() const
{
int registerResult = -1;
void *argv[] = { &registerResult };
mobj->static_metacall(QMetaObject::RegisterPropertyMetaType, data.index(mobj), argv);
return registerResult == -1 ? QMetaType::UnknownType : registerResult;
return typeId();
}
#endif
QMetaProperty::QMetaProperty(const QMetaObject *mobj, int index)
: mobj(mobj),

View File

@ -332,7 +332,10 @@ public:
inline const QMetaObject *enclosingMetaObject() const { return mobj; }
private:
#if QT_DEPRECATED_SINCE(6, 4)
QT_DEPRECATED_VERSION_X_6_4("obsolete, simply returns typeId()")
int registerPropertyType() const;
#endif
struct Data {
enum { Size = 5 };

View File

@ -1040,6 +1040,7 @@ void Generator::generateMetacall()
}
// ### Qt 7 (6.x?): remove
QMultiMap<QByteArray, int> Generator::automaticPropertyMetaTypesHelper()
{
QMultiMap<QByteArray, int> automaticPropertyMetaTypes;