diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2024-02-26 17:51:39 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2024-02-29 12:08:08 +0100 |
commit | 4ceb343e7f006972940b6880f974770c02fa6b87 (patch) | |
tree | d1a11bb3a0ebfce687d176dc6475949817453d1c /src/qml/qml/qqmltypewrapper.cpp | |
parent | c4aa0bb4a44ad78d80dab01d954f21d5a74f2845 (diff) |
QtQml: Remove fallback mode for finding singleton enums in metaobject
We always have a QQmlType these days and the QQmlType actually knows how
to look up enums, in contrast to the code removed here.
Pick-to: 6.7
Fixes: QTBUG-116057
Change-Id: Ief4b5c65da2e3c19668d4125b051356cc87bbeb6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmltypewrapper.cpp')
-rw-r--r-- | src/qml/qml/qqmltypewrapper.cpp | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index 0a707d4739..cce30c51c9 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -164,25 +164,11 @@ ReturnedValue QQmlTypeWrapper::create( return w.asReturnedValue(); } -static int enumForSingleton(QV4::ExecutionEngine *v4, String *name, QObject *qobjectSingleton, - const QQmlType &type, bool *ok) +static int enumForSingleton(QV4::ExecutionEngine *v4, String *name, const QQmlType &type, bool *ok) { Q_ASSERT(ok != nullptr); - int value = type.enumValue(QQmlEnginePrivate::get(v4->qmlEngine()), name, ok); - if (*ok) - return value; - - // ### Optimize - QByteArray enumName = name->toQString().toUtf8(); - const QMetaObject *metaObject = qobjectSingleton->metaObject(); - for (int ii = metaObject->enumeratorCount() - 1; ii >= 0; --ii) { - QMetaEnum e = metaObject->enumerator(ii); - value = e.keyToValue(enumName.constData(), ok); - if (*ok) - return value; - } - *ok = false; - return -1; + const int value = type.enumValue(QQmlEnginePrivate::get(v4->qmlEngine()), name, ok); + return *ok ? value : -1; } ReturnedValue QQmlTypeWrapper::virtualGet(const Managed *m, PropertyKey id, const Value *receiver, bool *hasProperty) @@ -220,7 +206,7 @@ ReturnedValue QQmlTypeWrapper::virtualGet(const Managed *m, PropertyKey id, cons const bool includeEnums = w->d()->mode == Heap::QQmlTypeWrapper::IncludeEnums; if (includeEnums && name->startsWithUpper()) { bool ok = false; - int value = enumForSingleton(v4, name, qobjectSingleton, type, &ok); + int value = enumForSingleton(v4, name, type, &ok); if (ok) return QV4::Value::fromInt32(value).asReturnedValue(); |