fix: app icon find mistake

Change-Id: Iae74053b57b8bb1accb36e7a5309eea567d6774c
This commit is contained in:
listenerri 2018-09-07 12:07:41 +08:00
parent e802e87e4b
commit 7ae40f4bb9
Notes: gerrit 2018-09-07 14:58:46 +08:00
Verified+1: <jenkins@deepin.com>
Code-Review+2: listenerri <listenerri@gmail.com>
Submitted-by: listenerri <listenerri@gmail.com>
Submitted-at: Fri, 07 Sep 2018 14:58:46 +0800
Reviewed-on: https://cr.deepin.io/38277
Project: dde/dde-dock
Branch: refs/heads/master

View File

@ -26,6 +26,7 @@
#include <QDebug>
#include <QApplication>
#include <QPixmapCache>
#include <QCryptographicHash>
ThemeAppIcon::ThemeAppIcon(QObject *parent) : QObject(parent)
{
@ -46,10 +47,7 @@ const QPixmap ThemeAppIcon::getIcon(const QString iconName, const int size)
QString key;
if (iconName.startsWith("data:image/")) {
key = QString("%1x%2x%3") \
.arg(size) \
.arg(ratio) \
.arg(iconName.mid(0, 20)); // incase the iconName is too long.
key = QCryptographicHash::hash(iconName.toUtf8(), QCryptographicHash::Md5).toHex();
// FIXME(hualet): The cache can reduce memory usage,
// that is ~2M on HiDPI enabled machine with 9 icons loaded,
@ -96,7 +94,9 @@ const QPixmap ThemeAppIcon::getIcon(const QString iconName, const int size)
pixmap = pixmap.scaled(s, s, Qt::KeepAspectRatio, Qt::SmoothTransformation);
pixmap.setDevicePixelRatio(ratio);
QPixmapCache::insert(key, pixmap);
if (!key.isEmpty()) {
QPixmapCache::insert(key, pixmap);
}
return pixmap;
}