diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-03-30 07:57:30 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-04-01 15:59:46 +0300 |
commit | d9df8c3f474b128b1631f1ff58ec2026ab21272d (patch) | |
tree | 7433fdb7b58b705aa1c9fc3030e70a83d058d782 | |
parent | 376b73789115833edbcdbed86d5e709cab2ab050 (diff) | |
download | subsurface-d9df8c3f474b128b1631f1ff58ec2026ab21272d.tar.gz |
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>
-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); }; |