diff options
| author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-02-19 09:58:48 +0100 |
|---|---|---|
| committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-02-19 18:12:36 +0100 |
| commit | 0cf6e06a8e936d36774fbcf953ea65ad1f7f0b8d (patch) | |
| tree | c7737c46941ad66070e9bed20b7d4a06ea8bb956 | |
| parent | 3b91f3a69a2679e69d056a53e9c7edc7e6d552a6 (diff) | |
QQmlMetaObject::methodReturnType: provide metatype
Task-number: QTBUG-82931
Change-Id: Ifbaf32d1c4af5064d94ec379fcb1667ce1c0502c
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| -rw-r--r-- | src/qml/jsruntime/qv4qobjectwrapper.cpp | 2 | ||||
| -rw-r--r-- | src/qml/qml/qqmlmetaobject.cpp | 32 | ||||
| -rw-r--r-- | src/qml/qml/qqmlmetaobject_p.h | 2 |
3 files changed, 11 insertions, 25 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 4a7a80d3bf..714e07cbad 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -1565,7 +1565,7 @@ static QV4::ReturnedValue CallPrecise(const QQmlObjectOrGadget &object, const QQ { QByteArray unknownTypeError; - int returnType = object.methodReturnType(data, &unknownTypeError); + int returnType = object.methodReturnType(data, &unknownTypeError).id(); if (returnType == QMetaType::UnknownType) { return engine->throwError(QLatin1String("Unknown method return type: ") diff --git a/src/qml/qml/qqmlmetaobject.cpp b/src/qml/qml/qqmlmetaobject.cpp index 89c08f3841..471868a91d 100644 --- a/src/qml/qml/qqmlmetaobject.cpp +++ b/src/qml/qml/qqmlmetaobject.cpp @@ -135,36 +135,22 @@ void QQmlMetaObject::resolveGadgetMethodOrPropertyIndex(QMetaObject::Call type, *index -= offset; } -int QQmlMetaObject::methodReturnType(const QQmlPropertyData &data, QByteArray *unknownTypeError) const +QMetaType QQmlMetaObject::methodReturnType(const QQmlPropertyData &data, QByteArray *unknownTypeError) const { Q_ASSERT(_m && data.coreIndex() >= 0); QMetaType type = data.propType(); - - const char *propTypeName = nullptr; - if (!type.isValid()) { // Find the return type name from the method info - QMetaMethod m = _m->method(data.coreIndex()); - - type = m.returnMetaType(); - propTypeName = m.typeName(); + type = _m->method(data.coreIndex()).returnMetaType(); } - - if (type.sizeOf() <= qsizetype(sizeof(int))) { - if (type.flags() & QMetaType::IsEnumeration) - return QMetaType::Int; - - if (isNamedEnumerator(_m, propTypeName)) - return QMetaType::Int; - - if (!type.isValid()) { - if (unknownTypeError) - *unknownTypeError = propTypeName; - } - } // else we know that it's a known type, as sizeOf(UnknownType) == 0 - - return type.id(); + if (type.flags().testFlag(QMetaType::IsEnumeration)) + type = QMetaType::fromType<int>(); + if (type.isValid()) + return type; + else if (unknownTypeError) + *unknownTypeError = _m->method(data.coreIndex()).typeName(); + return QMetaType(); } int *QQmlMetaObject::methodParameterTypes(int index, ArgTypeStorage *argStorage, diff --git a/src/qml/qml/qqmlmetaobject_p.h b/src/qml/qml/qqmlmetaobject_p.h index 9465458780..61e3e16a81 100644 --- a/src/qml/qml/qqmlmetaobject_p.h +++ b/src/qml/qml/qqmlmetaobject_p.h @@ -89,7 +89,7 @@ public: inline const QMetaObject *metaObject() const; - int methodReturnType(const QQmlPropertyData &data, QByteArray *unknownTypeError) const; + QMetaType methodReturnType(const QQmlPropertyData &data, QByteArray *unknownTypeError) const; int *methodParameterTypes(int index, ArgTypeStorage *argStorage, QByteArray *unknownTypeError) const; int *constructorParameterTypes(int index, ArgTypeStorage *dummy, QByteArray *unknownTypeError) const; |
