summaryrefslogtreecommitdiffstats
path: root/src/widgets/graphicsview/qgraphicsitem.cpp
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andrhans@cisco.com>2011-09-29 14:54:15 +0200
committerQt by Nokia <qt-info@nokia.com>2011-10-03 15:31:42 +0200
commite4207a79d14ee85fb4623e6903a64b0a596997f2 (patch)
tree9b8bbcd7ae7a07f4d3df123a35af8ffe8aaf1771 /src/widgets/graphicsview/qgraphicsitem.cpp
parent5ea2eab00d70c4dfef1050387c5db376aff95b39 (diff)
Fix bug in QGraphicsItem::isVisibleTo().
Task-number: QTBUG-21612 Reviewed-by: James Perrett Reviewed-by: Magne Pettersen Zachrisen Change-Id: I570c673a817c3c01593fcd7fa46d545f34e2c38d Merge-request: 1396 Reviewed-by: Jan-Arve Saether <jan-arve.saether@nokia.com> Reviewed-on: http://codereview.qt-project.org/5927 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
Diffstat (limited to 'src/widgets/graphicsview/qgraphicsitem.cpp')
-rw-r--r--src/widgets/graphicsview/qgraphicsitem.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp
index 07af928243..756c2f2aac 100644
--- a/src/widgets/graphicsview/qgraphicsitem.cpp
+++ b/src/widgets/graphicsview/qgraphicsitem.cpp
@@ -2238,7 +2238,8 @@ bool QGraphicsItem::isVisible() const
returned. \a parent can be 0, in which case this function will return
whether the item is visible to the scene or not.
- An item may not be visible to its ancestors even if isVisible() is true. If
+ An item may not be visible to its ancestors even if isVisible() is true. It
+ may also be visible to its ancestors even if isVisible() is false. If
any ancestor is hidden, the item itself will be implicitly hidden, in which
case this function will return false.
@@ -2246,15 +2247,16 @@ bool QGraphicsItem::isVisible() const
*/
bool QGraphicsItem::isVisibleTo(const QGraphicsItem *parent) const
{
- if (!d_ptr->visible)
+ const QGraphicsItem *p = this;
+ if (d_ptr->explicitlyHidden)
return false;
- if (parent == this)
- return true;
- if (parentItem() && parentItem()->isVisibleTo(parent))
- return true;
- if (!parent && !parentItem())
- return true;
- return false;
+ do {
+ if (p == parent)
+ return true;
+ if (p->d_ptr->explicitlyHidden)
+ return false;
+ } while ((p = p->d_ptr->parent));
+ return parent == 0;
}
/*!