From 8a12dd9ab4cb026591a6d9672d147ec4eb54a651 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 8 Sep 2009 10:48:36 +0200 Subject: Fix crash on QGraphicsItem destruction related to focus handling (redone) Reset the dangling subFocusItem pointer in ~QGraphicsItem, after all the child items have been deleted. This replaces commit d724c91a0ae. Reviewed-by: Thomas Hartmann --- src/gui/graphicsview/qgraphicsitem.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 8bd3648..73ea75e 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -930,7 +930,7 @@ void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent) } QGraphicsItem *lastSubFocusItem = subFocusItem; - if (subFocusItem && !inDestructor) { + if (subFocusItem) { // Update the child focus chain; when reparenting an item that has a // focus child, ensure that that focus child clears its focus child // chain from our parents before it's reparented. @@ -1204,6 +1204,8 @@ QGraphicsItem::~QGraphicsItem() Q_ASSERT(d_ptr->children.isEmpty()); } + d_ptr->subFocusItem = 0; + if (d_ptr->scene) { d_ptr->scene->d_func()->removeItemHelper(this); } else { -- cgit v0.12