From 56ef2860a03e67afcb66c0827f1f258c7ae7c86d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Fri, 24 Apr 2009 11:00:05 +0200 Subject: Fix a caching problem in QSvgIconEngine. The QIcon::pixmap() call would always load and validate any svg file that was used for a QIcon, even though there was a cached pixmap for that particular size. Task-number: 248848 Reviewed-by: Kim --- src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp index 7fdf81f..c7249d3 100644 --- a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp +++ b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp @@ -121,7 +121,7 @@ QSize QSvgIconEngine::actualSize(const QSize &size, QIcon::Mode mode, if (!pm.isNull() && pm.size() == size) return size; } - + QSvgRenderer renderer; d->loadDataForModeAndState(&renderer, mode, state); if (renderer.isValid()) { @@ -158,9 +158,13 @@ void QSvgIconEnginePrivate::loadDataForModeAndState(QSvgRenderer *renderer, QIco QPixmap QSvgIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) -{ +{ QPixmap pm; + QString pmckey(d->pmcKey(size, mode, state)); + if (QPixmapCache::find(pmckey, pm)) + return pm; + if (d->addedPixmaps) { pm = d->addedPixmaps->value(d->hashKey(mode, state)); if (!pm.isNull() && pm.size() == size) @@ -176,10 +180,6 @@ QPixmap QSvgIconEngine::pixmap(const QSize &size, QIcon::Mode mode, if (!actualSize.isNull()) actualSize.scale(size, Qt::KeepAspectRatio); - QString pmckey(d->pmcKey(actualSize, mode, state)); - if (QPixmapCache::find(pmckey, pm)) - return pm; - QImage img(actualSize, QImage::Format_ARGB32_Premultiplied); img.fill(0x00000000); QPainter p(&img); -- cgit v0.12