diff options
author | Andreas Aardal Hanssen <andrhans@cisco.com> | 2011-09-29 12:54:15 (GMT) |
---|---|---|
committer | Jan-Arve Saether <jan-arve.saether@nokia.com> | 2011-09-29 13:10:36 (GMT) |
commit | f3f65928525465e20f40e89d0855a1f32de6d8a4 (patch) | |
tree | 3c114b6fa7cd40953bf979cacb1f5d8899d41c6e /src/gui/graphicsview | |
parent | 569228bb5d7759025f06b1963f3d4a1fc4e05694 (diff) | |
download | Qt-f3f65928525465e20f40e89d0855a1f32de6d8a4.zip Qt-f3f65928525465e20f40e89d0855a1f32de6d8a4.tar.gz Qt-f3f65928525465e20f40e89d0855a1f32de6d8a4.tar.bz2 |
Fix bug in QGraphicsItem::isVisibleTo().
Task-number: QTBUG-21612
Reviewed-by: James Perrett
Reviewed-by: Magne Pettersen Zachrisen
Merge-request: 1396
Reviewed-by: Jan-Arve Saether <jan-arve.saether@nokia.com>
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r-- | src/gui/graphicsview/qgraphicsitem.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 9092593..f7ae045 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2237,7 +2237,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. @@ -2245,15 +2246,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; } /*! |