diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/imagedownloader.cpp | 11 | ||||
-rw-r--r-- | core/imagedownloader.h | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/core/imagedownloader.cpp b/core/imagedownloader.cpp index aaab9a434..8610d3454 100644 --- a/core/imagedownloader.cpp +++ b/core/imagedownloader.cpp @@ -6,6 +6,7 @@ #include "imagedownloader.h" #include <unistd.h> #include <QString> +#include <QImageReader> #include <QtConcurrent> @@ -102,6 +103,16 @@ static void loadPicture(struct picture *picture, bool fromHash) download.load(fromHash); } +// Overwrite QImage::load() so that we can perform better error reporting. +bool SHashedImage::load(const QString &fileName, const char *format) +{ + QImageReader reader(fileName, format); + static_cast<QImage&>(*this) = reader.read(); + if (isNull()) + qInfo() << "Error loading image" << fileName << (int)reader.error() << reader.errorString(); + return !isNull(); +} + SHashedImage::SHashedImage(struct picture *picture) : QImage() { QUrl url = QUrl::fromUserInput(localFilePath(QString(picture->filename))); diff --git a/core/imagedownloader.h b/core/imagedownloader.h index be196aaef..dc42aee4d 100644 --- a/core/imagedownloader.h +++ b/core/imagedownloader.h @@ -20,6 +20,7 @@ private: }; class SHashedImage : public QImage { + bool load(const QString &fileName, const char *format=nullptr); public: SHashedImage(struct picture *picture); }; |