Dive pictures: don't attempt reading the same image twice

If loading of an image failed, we tried to see if we find a
canonical filename in the cache. There's no point in rereading
the picture if the canonical and the original filename are
the same.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-05-16 10:26:47 +02:00 committed by Lubomir I. Ivanov
parent c3c2c2f606
commit afe8843509

View file

@ -115,7 +115,6 @@ static std::pair<QImage,bool> getHashedImage(const QString &file_in, bool tryDow
hashPicture(file); hashPicture(file);
} else if (tryDownload) { } else if (tryDownload) {
// This did not load anything. Let's try to get the image from other sources // This did not load anything. Let's try to get the image from other sources
// Let's try to load it locally via its hash
QString filenameLocal = localFilePath(qPrintable(file)); QString filenameLocal = localFilePath(qPrintable(file));
qDebug() << QStringLiteral("Translated filename: %1 -> %2").arg(file, filenameLocal); qDebug() << QStringLiteral("Translated filename: %1 -> %2").arg(file, filenameLocal);
if (filenameLocal.isNull()) { if (filenameLocal.isNull()) {
@ -125,8 +124,9 @@ static std::pair<QImage,bool> getHashedImage(const QString &file_in, bool tryDow
loadPicture(file, true); loadPicture(file, true);
stillLoading = true; stillLoading = true;
} else { } else {
// Load locally from translated file name // Load locally from translated file name if it is different
thumb = loadImage(filenameLocal); if (filenameLocal != file)
thumb = loadImage(filenameLocal);
if (!thumb.isNull()) { if (!thumb.isNull()) {
// Make sure the hash still matches the image file // Make sure the hash still matches the image file
hashPicture(filenameLocal); hashPicture(filenameLocal);