aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2022-09-06 16:01:28 +0200
committerSami Shalayel <sami.shalayel@qt.io>2022-09-28 10:46:37 +0200
commit6b4080e44ad0b81b4c4337e47deef674e13bd66f (patch)
tree16bc6025d0c9805c501721fc6b745cab28b33815 /src/qml
parent15c54416b12a6ce9fddccf59c1ad92fb4ba9e7a7 (diff)
QQmlVMEMetaObjectEndpoint: ensure property cache before accessing it
Otherwise the property cache might be null and lead to segmentation faults, e.g. when declaring aliases in qml. In dev, ensurePropertyCache() does not require the engine argument anymore such that this cherry-pick diverges here. To get the engine argument, use qjsEngine() on the object. If this fail, return. Fixes: QTBUG-106256 Change-Id: I568c973e1ba00531fbe22a41e2c6c3c09dfc2f02 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> (cherry picked from commit e0a00a691963e2c684f4dd857d042a3ffbebe959) Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index ee1b2058d1..9b5823740d 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -240,13 +240,14 @@ void QQmlVMEMetaObjectEndpoint::tryConnect()
if (!target)
return;
- QQmlData *targetDData = QQmlData::get(target, /*create*/false);
- if (!targetDData)
- return;
QQmlPropertyIndex encodedIndex = QQmlPropertyIndex::fromEncoded(aliasData->encodedMetaPropertyIndex);
int coreIndex = encodedIndex.coreIndex();
int valueTypeIndex = encodedIndex.valueTypeIndex();
- const QQmlPropertyData *pd = targetDData->propertyCache->property(coreIndex);
+ QJSEngine *engine = qjsEngine(target);
+ if (!engine)
+ return; // dont crash
+ const QQmlPropertyData *pd =
+ QQmlData::ensurePropertyCache(engine, target)->property(coreIndex);
if (pd && valueTypeIndex != -1 && !QQmlMetaType::valueType(pd->propType())) {
// deep alias
QQmlEnginePrivate *enginePriv = QQmlEnginePrivate::get(metaObject->compilationUnit->engine->qmlEngine());