diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2014-03-04 13:11:59 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-04 15:22:58 +0100 |
commit | dc9bf8ecdcc2ee59006c7ce2d57faadd755e9557 (patch) | |
tree | b0e87f923c77355be66616c3c39031e8fc83f7d4 /src/qml/qml/qqmlvmemetaobject.cpp | |
parent | 588da94cce7ee0d9e03908fd5be211a5b629511c (diff) |
Fix crash when accessing var properties in objects with invalid context
We've had two indepedent reports of people running into the issue of
their QML code accidentally trying to access var properties in item view
delegates that were on the path of destruction, i.e. their QQmlContext was
already marked as invalid. Any such access would cause a failing assertion
in debug builds or a crash in release builds.
This patch removes the dependency to QQmlContextData for accessing the
var properties and adds a test-case that covers this use-case.
This is a regression from Qt 5.1.x.
Task-number: QTBUG-37227
Change-Id: Icf55d5fa8c15e45974e78086e9e11b2401ea9bad
Reviewed-by: Albert Astals Cid <albert.astals@canonical.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlvmemetaobject.cpp')
-rw-r--r-- | src/qml/qml/qqmlvmemetaobject.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index f9cb9565b3..e599c37c0c 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -998,7 +998,7 @@ QV4::ReturnedValue QQmlVMEMetaObject::readVarProperty(int id) Q_ASSERT(id >= firstVarPropertyIndex); if (ensureVarPropertiesAllocated()) { - QV4::Scope scope(QQmlEnginePrivate::get(ctxt->engine)->v4engine()); + QV4::Scope scope(varProperties.engine()); QV4::ScopedObject o(scope, varProperties.value()); return o->getIndexed(id - firstVarPropertyIndex); } @@ -1009,10 +1009,11 @@ QVariant QQmlVMEMetaObject::readPropertyAsVariant(int id) { if (id >= firstVarPropertyIndex) { if (ensureVarPropertiesAllocated()) { - QV4::Scope scope(QQmlEnginePrivate::get(ctxt->engine)->v4engine()); + QV4::ExecutionEngine *v4 = varProperties.engine(); + QV4::Scope scope(v4); QV4::ScopedObject o(scope, varProperties.value()); QV4::ScopedValue val(scope, o->getIndexed(id - firstVarPropertyIndex)); - return QQmlEnginePrivate::get(ctxt->engine)->v8engine()->toVariant(val, -1); + return v4->v8Engine->toVariant(val, -1); } return QVariant(); } else { |