diff options
author | Yoann Lopes <yoann.lopes@nokia.com> | 2010-07-09 14:28:18 (GMT) |
---|---|---|
committer | Toby Tomkins <toby.tomkins@nokia.com> | 2010-07-15 03:22:31 (GMT) |
commit | dd529528112f174f12ebe39903ad15655d0fcf90 (patch) | |
tree | 59cdb0c66d91eb6744ce0a41530e625170deb616 /src/gui | |
parent | 855bc9b8e446982ab04fe4c4073b7c66821110be (diff) | |
download | Qt-dd529528112f174f12ebe39903ad15655d0fcf90.zip Qt-dd529528112f174f12ebe39903ad15655d0fcf90.tar.gz Qt-dd529528112f174f12ebe39903ad15655d0fcf90.tar.bz2 |
Fixes crash in QGraphicsScene::addItem().
Crashed because tabFocusFirst could end up being a dangling pointer when
removing an item from the scene before deleting it.
When setting tabFocusFirst in fixFocusChainBeforeReparenting, we now
check that the item is in the scene. If it is not, tabFocusFirst is set
to 0.
Autotest included.
Task-number: QTBUG-12056
Reviewed-by: Alexis Ménard <alexis.menard@nokia.com>
(cherry picked from commit 7d09f690d5b4c56699092444665d1879deb86a6e)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/graphicsview/qgraphicswidget_p.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp index 28070da..f7850ca 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.cpp +++ b/src/gui/graphicsview/qgraphicswidget_p.cpp @@ -761,7 +761,7 @@ void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *new QGraphicsWidget *firstOld = 0; bool wasPreviousNew = true; - + while (w != q) { bool isCurrentNew = q->isAncestorOf(w); if (isCurrentNew) { @@ -796,7 +796,7 @@ void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *new newScene = newParent->scene(); if (oldScene && newScene != oldScene) - oldScene->d_func()->tabFocusFirst = firstOld; + oldScene->d_func()->tabFocusFirst = (firstOld && firstOld->scene() == oldScene) ? firstOld : 0; QGraphicsItem *topLevelItem = newParent ? newParent->topLevelItem() : 0; QGraphicsWidget *topLevel = 0; |