aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2017-11-13 13:56:09 +0100
committerJani Heikkinen <jani.heikkinen@qt.io>2017-11-14 08:23:57 +0000
commitd188cdd7378e0e8b384fa812b5907638075d1206 (patch)
treee02a4e8100398d68e31eef2066797b0939fdf9c2
parent19f02c691f790e2b38a23a3955590383425784e7 (diff)
Fix crash with dangling context object pointers
This is a regression introduced by commit e22b624d9ab1f36021adb9cdbfa9b37054282bb8, where the object that owns the QML context would destroy the context upon destruction. Now the context may live longer and thus the context->contextObject pointer would become a dangling pointer. Task-number: QTBUG-64166 Change-Id: I1df631fa11187abdeff735d8891ad7907e8d4a3d Reviewed-by: Lars Knoll <lars.knoll@qt.io>
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index 26e6a81418..e3906f2a7e 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -1979,6 +1979,8 @@ void QQmlDelegateModelItem::destroyObject()
Q_ASSERT(data);
if (data->ownContext) {
data->ownContext->clearContext();
+ if (data->ownContext->contextObject == object)
+ data->ownContext->contextObject = nullptr;
data->ownContext = 0;
data->context = 0;
}