Details
-
Suggestion
-
Resolution: Fixed
-
P3: Somewhat important
-
4.5.3, 4.6.0
-
None
-
60061f679 (dev)
Description
Please add in file
($QTDIR)\src\plugins\iconengines\svgiconengine\qsvgiconengine.cpp
in the method QSvgIconEngine::addFile()
at line 219 the following condition
if (d->svgFiles.value(d->hashKey(mode, state)) != abs) { QSvgRenderer renderer(abs); if (renderer.isValid()) { d->stepSerialNum(); d->svgFiles.insert(d->hashKey(mode, state), abs); } }
This condition helps avoiding QSvgRenderer from needlessly loading and parsing a SVG document, if it has already been inserted to the internal hash.
In practice this happens very often because QSvgIconEngine::addFile() gets called always twice when using icons in this way QIcon(":/icons/IconA.svg"). The first call is done by QSvgIconPlugin::create() [src\plugins\iconengines\svgiconengine\main.cpp, line 75].
The second call is done by QIcon::addFile() [src\gui\image\qicon.cpp] after the QSvgIconEngine has been created.
When using a large amount of QIcons with SVGs in a UI this helps to speed up the application.
(I even went further and wrote my own new svg iconengine that uses a QCache of QSvgRenderer similar to QPixmapCache to preferably have each svg parsed only once regardless of the amount of rendered icon sizes.)
Attachments
Issue Links
- resulted in
-
QTBUG-135483 [REG 6.7-> 6.8] Loading order affects QIcon state and mode when adding svg images
-
- Reported
-
For Gerrit Dashboard: QTBUG-8151 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
563567,3 | QIcon: don't load image twice | dev | qt/qtbase | Status: MERGED | +2 | 0 |