summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorTrond Kjernåsen <trond@trolltech.com>2009-05-11 14:40:33 (GMT)
committerTrond Kjernåsen <trond@trolltech.com>2009-05-11 14:45:41 (GMT)
commit6200d413487517eadb8f4696d92a38fc73ba737c (patch)
tree8cabd894cb7c236caa1f98516597a1a7bb769193 /src/plugins
parentfecfc325bbd4decc0d61e10dc6536575c305f812 (diff)
downloadQt-6200d413487517eadb8f4696d92a38fc73ba737c.zip
Qt-6200d413487517eadb8f4696d92a38fc73ba737c.tar.gz
Qt-6200d413487517eadb8f4696d92a38fc73ba737c.tar.bz2
Improved caching of QSvgIconEngine::actualSize() calls.
If an application calls QIcon::actualSize() for SVG based icons, before the icon is drawn for the first time, the actualSize() call will result in the SVG file being loaded and parsed for each call. Instead of doing that, just render a pixmap of the queried size and then the resulting actualSize() calls will used the size of the cached pixmap. Task-number: related to 251106 Reviewed-by: Kim
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp
index c7249d3..3273513 100644
--- a/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp
+++ b/src/plugins/iconengines/svgiconengine/qsvgiconengine.cpp
@@ -122,16 +122,10 @@ QSize QSvgIconEngine::actualSize(const QSize &size, QIcon::Mode mode,
return size;
}
- QSvgRenderer renderer;
- d->loadDataForModeAndState(&renderer, mode, state);
- if (renderer.isValid()) {
- QSize defaultSize = renderer.defaultSize();
- if (!defaultSize.isNull())
- defaultSize.scale(size, Qt::KeepAspectRatio);
- return defaultSize;
- } else {
+ QPixmap pm = pixmap(size, mode, state);
+ if (pm.isNull())
return QSize();
- }
+ return pm.size();
}
void QSvgIconEnginePrivate::loadDataForModeAndState(QSvgRenderer *renderer, QIcon::Mode mode, QIcon::State state)