summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview/qgraphicsitem.cpp
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2010-02-17 12:47:26 (GMT)
committerYoann Lopes <yoann.lopes@nokia.com>2010-02-17 12:47:26 (GMT)
commita7ef2d899d711d750238a8d69284da808188b407 (patch)
tree2c74fc117a83168641b13ce575af5766321c2eef /src/gui/graphicsview/qgraphicsitem.cpp
parent100ea081145be48f7a091be5dee339255154b078 (diff)
downloadQt-a7ef2d899d711d750238a8d69284da808188b407.zip
Qt-a7ef2d899d711d750238a8d69284da808188b407.tar.gz
Qt-a7ef2d899d711d750238a8d69284da808188b407.tar.bz2
Fixes crash when destroying a QGraphicsItem.
When clearing the focus on an item, the focus was previously passed to the closest parent focus scope (if any). But the focus should go to the closest parent focus scope only if the item being cleared of the focus is itself a focus scope. This incorrect behavior leaded to invalid pointers in QGraphicsItem under specific circumstances, eventually leading to a crash when destroying the item. Auto-test included. Task-number: QT-2649 Reviewed-by: Andreas Aardal Hanssen
Diffstat (limited to 'src/gui/graphicsview/qgraphicsitem.cpp')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 63b0ec7..54914b3 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -3174,8 +3174,9 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim
*/
void QGraphicsItem::clearFocus()
{
- // Pass focus to the closest parent focus scope.
- if (!d_ptr->inDestructor) {
+ // Pass focus to the closest parent focus scope when clearing focus
+ // from a focus scope.
+ if (!d_ptr->inDestructor && (d_ptr->flags & ItemIsFocusScope)) {
QGraphicsItem *p = d_ptr->parent;
while (p) {
if (p->flags() & ItemIsFocusScope) {