diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-06-11 16:21:04 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-06-14 10:26:07 +0200 |
commit | 0f667f17195749deac47bc446b5aebb7cf09065e (patch) | |
tree | f4fbeb94dd213fec5cb95d22395189ec6b91535f | |
parent | 7625d207587c52a3686453ce615187cf6ab90996 (diff) |
Handle half-deleted scope objects in AOT lookups
Apparently we can still call bindings and functions on those. In
contrast to the QML engine, we throw a type error here, rather than
silently returning undefined.
Change-Id: I7d7daf1582d891f6acadb705b50dc36e23f8425c
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
(cherry picked from commit 29fccccb402be67f06852005ffcf20250897b13a)
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
-rw-r--r-- | src/qml/qml/qqml.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp index f5cdb910d7..fefbb66860 100644 --- a/src/qml/qml/qqml.cpp +++ b/src/qml/qml/qqml.cpp @@ -1112,7 +1112,9 @@ bool AOTCompiledContext::loadScopeObjectPropertyLookup(uint index, void *target) case ObjectPropertyResult::NeedsInit: return false; case ObjectPropertyResult::Deleted: - Q_UNREACHABLE(); // The scope object should really stay alive + engine->handle()->throwTypeError( + QStringLiteral("Cannot read property '%1' of null") + .arg(compilationUnit->runtimeStrings[l->nameIndex]->toQString())); return false; case ObjectPropertyResult::OK: return true; @@ -1124,12 +1126,15 @@ bool AOTCompiledContext::loadScopeObjectPropertyLookup(uint index, void *target) void AOTCompiledContext::initLoadScopeObjectPropertyLookup(uint index, QMetaType type) const { - Q_ASSERT(!engine->hasError()); + QV4::ExecutionEngine *v4 = engine->handle(); QV4::Lookup *l = compilationUnit->runtimeLookups + index; - if (initObjectLookup(this, l, qmlScopeObject, type)) + + if (v4->hasException) + amendException(v4); + else if (initObjectLookup(this, l, qmlScopeObject, type)) l->qmlContextPropertyGetter = QV4::QQmlContextWrapper::lookupScopeObjectProperty; else - engine->handle()->throwTypeError(); + v4->throwTypeError(); } bool AOTCompiledContext::loadTypeLookup(uint index, void *target) const |