summaryrefslogtreecommitdiffstats
path: root/tests/auto/qpixmapcache
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-04-27 14:31:58 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-04-27 14:35:53 (GMT)
commitae949b9d21470a9b9bf200774c246a0b86a69ff6 (patch)
treef2361cd740ddfdf9aae8af2fc72f5171757b85d9 /tests/auto/qpixmapcache
parente7fdaf47dfdf5e2f6056aa5d5b4644e74a05492a (diff)
downloadQt-ae949b9d21470a9b9bf200774c246a0b86a69ff6.zip
Qt-ae949b9d21470a9b9bf200774c246a0b86a69ff6.tar.gz
Qt-ae949b9d21470a9b9bf200774c246a0b86a69ff6.tar.bz2
QPixmapCache:Remove the old pixmap if you insert one with the same key.
If you insert a new pixmap in the cache with a key that was already in the cache then we remove the old pixmap and add the new one. This avoid to fill the memory with garbage even if the cache has a protection to avoid running out of memory. This was discovered with QraphicsView and its cache. We don't need to keep old cached pixmaps for an item. Task-number: KDE Reviewed-by: Trond
Diffstat (limited to 'tests/auto/qpixmapcache')
-rw-r--r--tests/auto/qpixmapcache/tst_qpixmapcache.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
index c163b52..1f515ff 100644
--- a/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
+++ b/tests/auto/qpixmapcache/tst_qpixmapcache.cpp
@@ -166,6 +166,16 @@ void tst_QPixmapCache::insert()
QVERIFY(estimatedNum - 1 <= num <= estimatedNum + 1);
QPixmap p3;
QPixmapCache::insert("null", p3);
+
+ QPixmap c1(10, 10);
+ c1.fill(Qt::yellow);
+ QPixmapCache::insert("custom", c1);
+ QVERIFY(!c1.isDetached());
+ QPixmap c2(10, 10);
+ c2.fill(Qt::red);
+ QPixmapCache::insert("custom", c2);
+ //We have deleted the old pixmap in the cache for the same key
+ QVERIFY(c1.isDetached());
}
void tst_QPixmapCache::remove()