From c546a8fab7dcd54353b1d8f427a3508b5caf32e9 Mon Sep 17 00:00:00 2001 From: Grigorii Zimin Date: Fri, 21 Feb 2020 11:37:05 +0300 Subject: Fix UB which caused SEGFAULT Fix CursorNavigationAttached destruction, which caused segfault when child instances called a method of the already deleted parent Fixes: AUTOSUITE-1485 Change-Id: Ib8937e28cdd79836954e488361b9bee3b2d9747c Reviewed-by: Egor Nemtsev --- plugin/cursornavigationattached.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugin/cursornavigationattached.cpp b/plugin/cursornavigationattached.cpp index 61ac5bd..c6a450f 100644 --- a/plugin/cursornavigationattached.cpp +++ b/plugin/cursornavigationattached.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2018, 2019 Luxoft Sweden AB. All rights reserved. +** Copyright (C) 2018 - 2020 Luxoft Sweden AB. All rights reserved. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the cursor management module of the Qt Toolkit. @@ -67,6 +67,11 @@ m_escapeTarget(nullptr) CursorNavigationAttached::~CursorNavigationAttached() { qCWarning(cursorNavigationLog) << "~CursorNavigationAttached"; + + for (auto && child: m_children) { + child->m_parentNavigable = nullptr; + } + if (m_cursorNavigation) m_cursorNavigation->unregisterItem(this); } -- cgit v1.2.3