summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2011-09-09 07:51:18 (GMT)
committerSamuel Rødal <samuel.rodal@nokia.com>2011-09-09 08:19:22 (GMT)
commit7ab0bed3a56d46c386e65abc381264c57137cb43 (patch)
tree1c6e26116aac3a2bc57ac26692f5262aecbf95cd /src/corelib/tools
parent786b85b13bc884a8b7eab59c43d6c393863fc470 (diff)
downloadQt-7ab0bed3a56d46c386e65abc381264c57137cb43.zip
Qt-7ab0bed3a56d46c386e65abc381264c57137cb43.tar.gz
Qt-7ab0bed3a56d46c386e65abc381264c57137cb43.tar.bz2
Prevent QPixmapCache potentially growing indefinitely.
QPixmapCache has until now refused to throw out shared pixmaps, i.e. ones that still have shallow copies lying around. This leads to problems when someone inserts two shallow copies using different keys, causing the cache itself containing multiple shallow copies and thus forever refusing to throw out those entries. It's rather easy for this to accidentally happen in a user application since QPixmap::load() or QPixmap(const QString &fileName, ...) automatically cache the pixmap in the QPixmapCache, thus if the user then calls QPixmapCache::insert() on the same pixmap or a shallow copy it is locked in the QPixmapCache forever. The only reason for not throwing out a pixmap that's shared would be to prevent re-loading a pixmap from file when a user has a direct reference to it in his application, but in that case the user is unlikely to re-load the pixmap from file in any case. Therefore it seems the best fix is to get rid of this limitation. Task-number: QTBUG-21359 Reviewed-by: John Brooks Reviewed-by: Olivier Goffart
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qcache.h3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/corelib/tools/qcache.h b/src/corelib/tools/qcache.h
index 16861c9..2408cd3 100644
--- a/src/corelib/tools/qcache.h
+++ b/src/corelib/tools/qcache.h
@@ -205,8 +205,7 @@ void QCache<Key,T>::trim(int m)
while (n && total > m) {
Node *u = n;
n = n->p;
- if (qIsDetached(*u->t))
- unlink(*u);
+ unlink(*u);
}
}