summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-04-21 13:57:05 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-04-21 14:02:39 (GMT)
commit08feb22f9a924ce120da8b5c6e1669d2a630dd54 (patch)
tree3fc34e896810ca0805dbe9a86f088fcf35211456 /src
parent924feac07729b680fbd337e3773c747b64e1da61 (diff)
downloadQt-08feb22f9a924ce120da8b5c6e1669d2a630dd54.zip
Qt-08feb22f9a924ce120da8b5c6e1669d2a630dd54.tar.gz
Qt-08feb22f9a924ce120da8b5c6e1669d2a630dd54.tar.bz2
BT: Fix update regression for cached QGraphicsItem (Elastic Nodes stuck)
This fixes a bug in 4.5.0 where cached items that call update() after they have been moved or transformed failed to get a call to paint(), so the last cache image was used to draw. The easiest way to reproduce this bug is in the Elastic Nodes example. If you press, wait, then release, the nodes will consistently move to sunken state, then back to normal state. But if you click quickly while moving the mouse, the nodes will stay sunken. The bug was that the item was marked as dirty as a result of being moved, and when the mouse button was released, the node item's call to update() was discarded, as the item was "already dirty". The fix is to allow invalidation of the cache even if the item is marked as dirty. Reviewed-by: bnilsen
Diffstat (limited to 'src')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index d1b8393..3e8d38f 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -3950,17 +3950,29 @@ bool QGraphicsItemPrivate::isProxyWidget() const
*/
void QGraphicsItem::update(const QRectF &rect)
{
- if ((rect.isEmpty() && !rect.isNull()) || d_ptr->discardUpdateRequest())
+ if (rect.isEmpty() && !rect.isNull())
return;
if (CacheMode(d_ptr->cacheMode) != NoCache) {
QGraphicsItemCache *cache = d_ptr->extraItemCache();
+ if (d_ptr->discardUpdateRequest(/* ignoreVisibleBit = */ false,
+ /* ignoreClipping = */ false,
+ /* ignoreDirtyBit = */ true)) {
+ return;
+ }
+
+ // Invalidate cache.
if (rect.isNull()) {
cache->allExposed = true;
cache->exposed.clear();
} else {
cache->exposed.append(rect);
}
+ // Only invalidate cache; item is already dirty.
+ if (d_ptr->dirty)
+ return;
+ } else if (d_ptr->discardUpdateRequest()) {
+ return;
}
// Effectively the same as updateHelper(rect);