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

Remove extra thumbnail isNull check

In case the cached thumbnail loaded successfully the isNull check is
unreachable due to the early `return true`.
parent faecc6ae
......@@ -676,29 +676,26 @@ bool ThumbnailProtocol::createSubThumbnail(QImage& thumbnail, const QString& fil
}
}
if (thumbnail.isNull()) {
// no cached version is available, a new thumbnail must be created
ThumbCreator* subCreator = getSubCreator();
if (subCreator && subCreator->create(filePath, cacheSize, cacheSize, thumbnail)) {
scaleDownImage(thumbnail, cacheSize, cacheSize);
// The thumbnail has been created successfully. Store the thumbnail
// to the cache for future access.
QSaveFile thumbnailfile(thumbPath.absoluteFilePath(thumbName));
if (thumbnailfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
QFileInfo fi(filePath);
thumbnail.setText(QStringLiteral("Thumb::URI"), QString::fromUtf8(fileUrl));
thumbnail.setText(QStringLiteral("Thumb::MTime"), QString::number(fi.lastModified().toSecsSinceEpoch()));
thumbnail.setText(QStringLiteral("Thumb::Size"), QString::number(fi.size()));
if (thumbnail.save(&thumbnailfile, "png")) {
thumbnailfile.commit();
}
// no cached version is available, a new thumbnail must be created
ThumbCreator* subCreator = getSubCreator();
if (subCreator && subCreator->create(filePath, cacheSize, cacheSize, thumbnail)) {
scaleDownImage(thumbnail, cacheSize, cacheSize);
// The thumbnail has been created successfully. Store the thumbnail
// to the cache for future access.
QSaveFile thumbnailfile(thumbPath.absoluteFilePath(thumbName));
if (thumbnailfile.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
QFileInfo fi(filePath);
thumbnail.setText(QStringLiteral("Thumb::URI"), QString::fromUtf8(fileUrl));
thumbnail.setText(QStringLiteral("Thumb::MTime"), QString::number(fi.lastModified().toSecsSinceEpoch()));
thumbnail.setText(QStringLiteral("Thumb::Size"), QString::number(fi.size()));
if (thumbnail.save(&thumbnailfile, "png")) {
thumbnailfile.commit();
}
} else {
return false;
}
} else {
return false;
}
} else {
ThumbCreator* subCreator = getSubCreator();
......
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