From d188cdd7378e0e8b384fa812b5907638075d1206 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 13 Nov 2017 13:56:09 +0100 Subject: 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 --- src/qml/types/qqmldelegatemodel.cpp | 2 ++ 1 file changed, 2 insertions(+) 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; } -- cgit v1.2.3