summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2010-07-13 12:21:44 (GMT)
committerToby Tomkins <toby.tomkins@nokia.com>2010-07-15 03:22:20 (GMT)
commit855bc9b8e446982ab04fe4c4073b7c66821110be (patch)
tree6d363ca0755dd39709eba099cff6df79c7cb6123 /src
parent9585d98469903df64c6772d37c6aa71a2f82389c (diff)
downloadQt-855bc9b8e446982ab04fe4c4073b7c66821110be.zip
Qt-855bc9b8e446982ab04fe4c4073b7c66821110be.tar.gz
Qt-855bc9b8e446982ab04fe4c4073b7c66821110be.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> (cherry picked from commit b5b011a181bd187dcef5ee8f46a3ac2c5dc2e09c)
Diffstat (limited to 'src')
-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 51dc543..5c444f1 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.
@@ -7634,9 +7636,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;
}