mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
376b737891
commit
d9df8c3f47
2 changed files with 12 additions and 0 deletions
|
@ -6,6 +6,7 @@
|
||||||
#include "imagedownloader.h"
|
#include "imagedownloader.h"
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QImageReader>
|
||||||
|
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
|
|
||||||
|
@ -102,6 +103,16 @@ static void loadPicture(struct picture *picture, bool fromHash)
|
||||||
download.load(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()
|
SHashedImage::SHashedImage(struct picture *picture) : QImage()
|
||||||
{
|
{
|
||||||
QUrl url = QUrl::fromUserInput(localFilePath(QString(picture->filename)));
|
QUrl url = QUrl::fromUserInput(localFilePath(QString(picture->filename)));
|
||||||
|
|
|
@ -20,6 +20,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
class SHashedImage : public QImage {
|
class SHashedImage : public QImage {
|
||||||
|
bool load(const QString &fileName, const char *format=nullptr);
|
||||||
public:
|
public:
|
||||||
SHashedImage(struct picture *picture);
|
SHashedImage(struct picture *picture);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue