From 01bc34088eb8e7fb4842fa1c2117cddbac086136 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 30 Apr 2013 10:35:06 +0300 Subject: Fix tabFocusFirst when that item is removed from QGraphicsScene MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If tabFocusFirst is not cleared or set to another valid item, there will be crash later if the removed item is deleted after removal. Task-number: QTBUG-30923 Change-Id: Iba9a6ce9334c52f8e552b0accda95ebb5fcfcdb1 Reviewed-by: Jan Arve Sæther --- src/widgets/graphicsview/qgraphicsscene.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 8a0b983c73..88cccb5118 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -637,6 +637,15 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) if (item == lastActivePanel) lastActivePanel = 0; + // Change tabFocusFirst to the next widget in focus chain if removing the current one. + if (item == tabFocusFirst) { + QGraphicsWidgetPrivate *wd = tabFocusFirst->d_func(); + if (wd->focusNext && wd->focusNext != tabFocusFirst && wd->focusNext->scene() == q) + tabFocusFirst = wd->focusNext; + else + tabFocusFirst = 0; + } + // Cancel active touches { QMap::iterator it = itemForTouchPointId.begin(); -- cgit v1.2.3