From 874539649508cc1a9cd0ec7ab45b374d18c2c4e5 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 8 Sep 2017 09:43:21 +0200 Subject: Fix crash with loading cache files originating from top-level components If a .qml file starts with Component {} and its item(s) define their own properties, alias, etc. then loading this file initially would work, but loading it from a cache file would crash with dangling pointers in the property cache. This was due to us registering aliases, properties, etc. twice in the property cache, exceeding the reservation in the property cache vectors. The minimal fix is to skip the root object in the property cache creating loop as we do handle it separately afterwards. It needs to be separate because the first object index within the component does not stem from a binding. However as the root object index is always zero, I'll make a follow-up patch to get rid of of the variable. Task-number: QTBUG-62263 Change-Id: I86b76d38cb490750a561eac2b0ad6fff6ef2e20a Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/qml/compiler/qqmlpropertycachecreator_p.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qml/compiler/qqmlpropertycachecreator_p.h b/src/qml/compiler/qqmlpropertycachecreator_p.h index 8fc8943366..2dd2e82651 100644 --- a/src/qml/compiler/qqmlpropertycachecreator_p.h +++ b/src/qml/compiler/qqmlpropertycachecreator_p.h @@ -562,6 +562,8 @@ template inline void QQmlPropertyCacheAliasCreator::appendAliasPropertiesToMetaObjects() { for (int i = 0; i < objectContainer->objectCount(); ++i) { + if (i == objectContainer->rootObjectIndex()) + continue; const CompiledObject &component = *objectContainer->objectAt(i); if (!(component.flags & QV4::CompiledData::Object::IsComponent)) continue; -- cgit v1.2.3