summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2010-07-13 12:21:44 (GMT)
committerYoann Lopes <yoann.lopes@nokia.com>2010-07-13 13:07:33 (GMT)
commitb5b011a181bd187dcef5ee8f46a3ac2c5dc2e09c (patch)
tree60b9ffbc1b26a18e21312fab6f9be065f868939c /src/gui
parent7d09f690d5b4c56699092444665d1879deb86a6e (diff)
downloadQt-b5b011a181bd187dcef5ee8f46a3ac2c5dc2e09c.zip
Qt-b5b011a181bd187dcef5ee8f46a3ac2c5dc2e09c.tar.gz
Qt-b5b011a181bd187dcef5ee8f46a3ac2c5dc2e09c.tar.bz2
Fixes QGraphicsItem::focusItem() returning incorrect value.
When setting focus on an item, subfocus chain was previously updated only for items with a common ancestor. We now make sure that this chain is updated also for the previously focused item (possibly not sharing any common ancestor with the newly focused item). Autotest included. Task-number: QTBUG-12112 Reviewed-by: Alexis Ménard <alexis.menard@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 848de2c..fe2a84e 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -3257,6 +3257,8 @@ void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool clim
}
// Update the child focus chain.
+ if (scene && scene->focusItem())
+ scene->focusItem()->d_ptr->clearSubFocus();
f->d_ptr->setSubFocus();
// Update the scene's focus item.
@@ -7637,9 +7639,9 @@ int QGraphicsItemPrivate::children_count(QDeclarativeListProperty<QGraphicsObjec
QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGraphicsObject> *list, int index)
{
QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));
- if (index >= 0 && index < d->children.count())
+ if (index >= 0 && index < d->children.count())
return d->children.at(index)->toGraphicsObject();
- else
+ else
return 0;
}