Commit ae949b9d21470a9b9bf200774c246a0b86a69ff6
- Diff rendering mode:
- inline
- side by side
src/gui/image/qpixmapcache.cpp
(5 / 0)
|   | |||
| 187 | 187 | cacheKeys.insert(key, cacheKey); | |
| 188 | 188 | return true; | |
| 189 | 189 | } | |
| 190 | qint64 oldCacheKey = cacheKeys.value(key, -1); | ||
| 191 | //If for the same key we add already a pixmap we should delete it | ||
| 192 | if (oldCacheKey != -1) | ||
| 193 | QCache<qint64, QDetachedPixmap>::remove(oldCacheKey); | ||
| 194 | |||
| 190 | 195 | bool success = QCache<qint64, QDetachedPixmap>::insert(cacheKey, new QDetachedPixmap(pixmap), cost); | |
| 191 | 196 | if (success) { | |
| 192 | 197 | cacheKeys.insert(key, cacheKey); |
tests/auto/qpixmapcache/tst_qpixmapcache.cpp
(10 / 0)
|   | |||
| 166 | 166 | QVERIFY(estimatedNum - 1 <= num <= estimatedNum + 1); | |
| 167 | 167 | QPixmap p3; | |
| 168 | 168 | QPixmapCache::insert("null", p3); | |
| 169 | |||
| 170 | QPixmap c1(10, 10); | ||
| 171 | c1.fill(Qt::yellow); | ||
| 172 | QPixmapCache::insert("custom", c1); | ||
| 173 | QVERIFY(!c1.isDetached()); | ||
| 174 | QPixmap c2(10, 10); | ||
| 175 | c2.fill(Qt::red); | ||
| 176 | QPixmapCache::insert("custom", c2); | ||
| 177 | //We have deleted the old pixmap in the cache for the same key | ||
| 178 | QVERIFY(c1.isDetached()); | ||
| 169 | 179 | } | |
| 170 | 180 | ||
| 171 | 181 | void tst_QPixmapCache::remove() |
Comments
Add a new comment:
Login or create an account to post a comment
Add your comment
Please log in to comment

