diff options
author | Alexis Menard <alexis.menard@nokia.com> | 2009-12-09 16:07:13 +0100 |
---|---|---|
committer | Alexis Menard <alexis.menard@nokia.com> | 2009-12-09 16:55:19 +0100 |
commit | 293db01f907ad8644e8242055521e6b8e7c4dfec (patch) | |
tree | 5c872a9bdcf7dd4742e8fbcfd7c0835cab59a8b5 /src/gui/graphicsview/qgraphicswidget_p.cpp | |
parent | 0dfb4c79dd6fb23fea5277c687485d43b0f91e3f (diff) | |
download | qt4-tools-293db01f907ad8644e8242055521e6b8e7c4dfec.tar.gz |
Fix a crash on the focus chain when removing items from the scene.
The crash was because of the dangling pointer set on the tabFocusFirst
attribute in QGraphicsScene. A child which was the tabFocusFirst was
removed from the scene and fixFocusChainBeforeReparenting was setting the
new tabFocusFirst pointer to the parent (since in that example it was
the focusNext) but later on the parent was removed also from the scene
(due to the recursion of removeItem if you call it with the parent :
first children, then the parent itself) and
fixFocusChainBeforeReparenting was not called again so if you delete
the parent then the scene has the dangling pointer set.
Task-number:QTBUG-6544
Reviewed-by:janarve
Diffstat (limited to 'src/gui/graphicsview/qgraphicswidget_p.cpp')
-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 b747a30649..5b6490fa4d 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.cpp +++ b/src/gui/graphicsview/qgraphicswidget_p.cpp @@ -743,7 +743,7 @@ bool QGraphicsWidgetPrivate::hasDecoration() const /** * is called after a reparent has taken place to fix up the focus chain(s) */ -void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *newScene) +void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *newParent, QGraphicsScene *oldScene, QGraphicsScene *newScene) { Q_Q(QGraphicsWidget); @@ -789,7 +789,7 @@ void QGraphicsWidgetPrivate::fixFocusChainBeforeReparenting(QGraphicsWidget *new // update tabFocusFirst for oldScene if the item is going to be removed from oldScene if (newParent) newScene = newParent->scene(); - QGraphicsScene *oldScene = q->scene(); + if (oldScene && newScene != oldScene) oldScene->d_func()->tabFocusFirst = firstOld; |