[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui/icons
From: Michael Pyne <mpyne () kde ! org>
Date: 2010-05-22 0:44:57
Message-ID: 20100522004457.56FF8AC8BC () svn ! kde ! org
[Download RAW message or body]
SVN commit 1129340 by mpyne:
When we cache "unknown" icons, only cache the image, do not cache the path. By doing this
we can properly handle the "canReturnNull" parameter if it changes on a later call to
loadIcon. This should fix the unit tests for KIconLoader (they all pass for me now)
CCMAIL:dfaure@kde.org
M +21 -1 kiconloader.cpp
--- trunk/KDE/kdelibs/kdeui/icons/kiconloader.cpp #1129339:1129340
@@ -790,7 +790,7 @@
// Not a SVG or SVGZ
img = QImage(path, ext.toLatin1());
- if (size != 0) {
+ if (size != 0 && !img.isNull()) {
img = img.scaled(size, size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
}
@@ -1217,12 +1217,21 @@
// See if the image is already cached.
QString key = d->makeCacheKey(name, group, overlays, size, state);
QPixmap pix;
+ bool iconWasUnknown = false;
K3Icon icon;
if (d->findCachedPixmapWithPath(key, pix, icon.path)) {
+ // We cache the pixmap for the event of trying to find an unknown icon
+ // with canReturnNull set to false, but if we *can* return null then
+ // we should do so when necessary.
+ if (canReturnNull && icon.path.isEmpty()) {
+ return QPixmap();
+ }
+
if (path_store) {
*path_store = icon.path;
}
+
return pix;
}
@@ -1260,6 +1269,7 @@
// We keep going in the function so we can ensure this result gets cached.
if (icon.path.isEmpty() && !canReturnNull) {
icon.path = d->unknownIconPath(size);
+ iconWasUnknown = true;
}
QImage img = d->createIconImage(icon.path, size);
@@ -1293,8 +1303,18 @@
// have to transfer so much to the graphics card.
d->drawOverlays(this, group, state, pix, overlays);
+ // Don't add the path to our unknown icon to the cache, only cache the
+ // actual image.
+ if (iconWasUnknown) {
+ icon.path = QString();
+ }
+
d->insertCachedPixmapWithPath(key, pix, icon.path);
+ if (path_store) {
+ *path_store = icon.path;
+ }
+
return pix;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic