aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-02-27 11:56:36 +0100
committerUlf Hermann <ulf.hermann@qt.io>2023-03-02 15:38:48 +0100
commit03984861278d4a23a3d7609feb1aebdaec1b609a (patch)
treeaf483624248d54018488580d601f20b57f1bbf61 /src
parentf38bd5eb303d0c2effeed405687008441acf6d6a (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. 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> (cherry picked from commit 8cbb30a650c2a2c8fb4b8cc39f347ff370850e74)
Diffstat (limited to 'src')
-rw-r--r--src/qml/qml/qqml.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp
index eba837f694..4df8472a8b 100644
--- a/src/qml/qml/qqml.cpp
+++ b/src/qml/qml/qqml.cpp
@@ -1488,7 +1488,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;