Icons: warn about invalid resources

Also give a 1x1 pixmap back to avoid paint engine error messages.

Change-Id: Ibd7793d133952c4c3169796432b42572af0ace21
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Tim Jenssen
2017-07-26 17:16:27 +02:00
parent b29ea4527a
commit 8f9e537dcf

View File

@@ -36,6 +36,7 @@
#include <QPainter> #include <QPainter>
#include <QPaintEngine> #include <QPaintEngine>
#include <QWidget> #include <QWidget>
#include <QDebug>
namespace Utils { namespace Utils {
@@ -67,7 +68,12 @@ static MasksAndColors masksAndColors(const Icon &icon, int dpr)
const QColor color = creatorTheme()->color(i.second); const QColor color = creatorTheme()->color(i.second);
const QString dprFileName = StyleHelper::availableImageResolutions(i.first).contains(dpr) ? const QString dprFileName = StyleHelper::availableImageResolutions(i.first).contains(dpr) ?
StyleHelper::imageFileWithResolution(fileName, dpr) : fileName; StyleHelper::imageFileWithResolution(fileName, dpr) : fileName;
result.append(qMakePair(QPixmap(dprFileName), color)); QPixmap pixmap;
if (!pixmap.load(dprFileName)) {
pixmap = QPixmap(1, 1);
qWarning() << "Could not load image: " << dprFileName;
}
result.append({pixmap, color});
} }
return result; return result;
} }