summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-03-30 07:57:30 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-04-01 15:59:46 +0300
commitd9df8c3f474b128b1631f1ff58ec2026ab21272d (patch)
tree7433fdb7b58b705aa1c9fc3030e70a83d058d782
parent376b73789115833edbcdbed86d5e709cab2ab050 (diff)
downloadsubsurface-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.cpp11
-rw-r--r--core/imagedownloader.h1
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);
};