Only return QPixmap when it is not null

QFile::exists() returns true even for executables in $PATH, and loading
those files with QPixmap() will return a null object.

Change-Id: I29a954aa2d504ca051b7328978426b6b993da753
This commit is contained in:
Felix Yan 2017-02-20 20:05:26 +08:00
parent b0c14898f3
commit 90e102335b
Notes: Deepin Code Review 2017-02-21 09:15:35 +08:00
Verified+1: Anonymous Coward #1000004
Code-Review+2: Hualet Wang <mr.asianwang@gmail.com>
Submitted-by: Hualet Wang <mr.asianwang@gmail.com>
Submitted-at: Tue, 21 Feb 2017 09:15:31 +0800
Reviewed-on: https://cr.deepin.io/20482
Project: dde/dde-dock
Branch: refs/heads/master

View File

@ -18,8 +18,11 @@ QPixmap ThemeAppIcon::getIcon(const QString iconName, const int size)
{
QPixmap pixmap(size, size);
if (QFile::exists(iconName))
return QPixmap(iconName);
if (QFile::exists(iconName)) {
pixmap = QPixmap(iconName);
if (!pixmap.isNull())
return pixmap;
}
if (iconName.startsWith("data:image/"))
{
const QStringList strs = iconName.split("base64,");