Commit ef76b22b authored by Stefan Brüns's avatar Stefan Brüns
Browse files

Avoid pointless probing for nonexisting thumbnail images

QImage::load(<path>) tries to find a fallback image if the file does
not exist, by appending extensions of all supported file formats, as
QImageReader defaults to format autodetection.

Check if the file exists, and only then try to load it.
parent c2e576ab
......@@ -668,12 +668,14 @@ bool ThumbnailProtocol::createSubThumbnail(QImage& thumbnail, const QString& fil
thumbPath.cd("large");
}
if (thumbnail.load(thumbPath.absoluteFilePath(thumbName))) {
QFile thumbFile(thumbPath.absoluteFilePath(thumbName));
if (thumbFile.open(QIODevice::ReadOnly) && thumbnail.load(&thumbFile, "png")) {
return true;
} else if (cacheSize == 128) {
QDir fallbackPath(m_thumbBasePath);
fallbackPath.cd("large");
if (thumbnail.load(fallbackPath.absoluteFilePath(thumbName))) {
QFile fallbackThumbFile(fallbackPath.absoluteFilePath(thumbName));
if (fallbackThumbFile.open(QIODevice::ReadOnly) && thumbnail.load(&fallbackThumbFile, "png")) {
return true;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment