Debug: Error reporting for SHashedImage loading

Overwrite QImage::load() in SHashedImage so that we can perform better
error reporting.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-03-30 07:57:30 +02:00 committed by Lubomir I. Ivanov
parent 376b737891
commit d9df8c3f47
2 changed files with 12 additions and 0 deletions

View file

@ -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)));

View file

@ -20,6 +20,7 @@ private:
};
class SHashedImage : public QImage {
bool load(const QString &fileName, const char *format=nullptr);
public:
SHashedImage(struct picture *picture);
};