From eb3d5a73148cd7206c6b3b6672ed47b44611f745 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 4fc0aed..d67011b 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -934,7 +934,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. @@ -1226,6 +1226,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