diff options
author | David Edmundson <davidedmundson@kde.org> | 2017-07-10 17:26:59 +0100 |
---|---|---|
committer | Valery Volgutov <valery.volgutov@lge.com> | 2018-05-08 06:36:16 +0000 |
commit | 3b4d27bf55348751ff6b454e834c0d0634d759b4 (patch) | |
tree | adb4eefdb0d68aa118700da13baa9843fbb26be2 | |
parent | e2218f8b5c527a6da52ae4dc8a381b3ff68d3cd0 (diff) |
Rebuild QQmlData::propertyCache if deleted by another engine
QQmlData is shared between engines, but the relevant QObjectWrapper is
not. Since 749a7212e903d8e8c6f256edb1836b9449cc7fe1 when a
QObjectWrapper is deleted it resets the shared QQmlData propertyCache.
In most cases the propertyCache except when a property updated in an
existing binding in the first engine, where it currently asserts.
Task-number: QTBUG-61681
Change-Id: I6efdc506e5c7e30b95cda1be282afa9feb781cd2
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
(cherry picked from commit ab5d4c78224c9ec79165e8890e5f8b8e838e0709)
-rw-r--r-- | src/qml/qml/qqmlbinding.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index f8b737a62a..cce4c493b4 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -485,7 +485,12 @@ QQmlPropertyData QQmlBinding::getPropertyData() const int valueTypeIndex = QQmlPropertyData::decodeValueTypePropertyIndex(m_targetIndex, &coreIndex); QQmlData *data = QQmlData::get(*m_target, false); - Q_ASSERT(data && data->propertyCache); + Q_ASSERT(data); + + if (Q_UNLIKELY(!data->propertyCache)) { + data->propertyCache = QQmlEnginePrivate::get(context()->engine)->cache(m_target->metaObject()); + data->propertyCache->addref(); + } QQmlPropertyData *propertyData = data->propertyCache->property(coreIndex); Q_ASSERT(propertyData); |