diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2023-02-27 11:56:36 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2023-03-01 11:56:19 +0100 |
commit | 8cbb30a650c2a2c8fb4b8cc39f347ff370850e74 (patch) | |
tree | 80a26db3a03f42e4ac6bfaf03ed0059ecd48ea43 /src/qml/qml/qqml.cpp | |
parent | 0bb5a91d8d9b227dccd93d46b97668c14e20101d (diff) |
QtQml: Always throw when requesting an enum from an invalid singleton
The interpreter does this and so should the enum lookup adapter for
generated C++ code.
Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-109816
Change-Id: I576480c3ca808743ddc0ceaf2f0bd8a1de776a41
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/qqml.cpp')
-rw-r--r-- | src/qml/qml/qqml.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp index 37eb52755e..466c9c98db 100644 --- a/src/qml/qml/qqml.cpp +++ b/src/qml/qml/qqml.cpp @@ -1777,7 +1777,12 @@ void AOTCompiledContext::initGetEnumLookup( { Q_ASSERT(!engine->hasError()); QV4::Lookup *l = compilationUnit->runtimeLookups + index; - Q_ASSERT(metaObject); + if (!metaObject) { + engine->handle()->throwTypeError( + QStringLiteral("Cannot read property '%1' of undefined") + .arg(QString::fromUtf8(enumValue))); + return; + } const int enumIndex = metaObject->indexOfEnumerator(enumerator); const int value = metaObject->enumerator(enumIndex).keyToValue(enumValue); l->qmlEnumValueLookup.encodedEnumValue = value; |