From e7b0998325a66ecb9f979f253d732db85e1f43d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Tue, 19 Jan 2010 16:52:22 +0100 Subject: QGraphicsItem::hasFocus() performance regression. Problem was that we always climbed the parent chain to look for a panel item (QGraphicsItem::isActive()) before checking the scene's focus item. Task-number: QTBUG-6749 Reviewed-by: alexis --- src/gui/graphicsview/qgraphicsitem.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index cae9660..1361a89 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2997,9 +2997,16 @@ void QGraphicsItem::setActive(bool active) */ bool QGraphicsItem::hasFocus() const { + if (!d_ptr->scene || !d_ptr->scene->isActive()) + return false; + if (d_ptr->focusProxy) return d_ptr->focusProxy->hasFocus(); - return isActive() && (d_ptr->scene && d_ptr->scene->focusItem() == this); + + if (d_ptr->scene->d_func()->focusItem != this) + return false; + + return panel() == d_ptr->scene->d_func()->activePanel; } /*! -- cgit v0.12