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

Move thumbnail QSaveFile to correct scope

The QSaveFile is only needed if there is thumbnail creator for the
format of the current file.
parent 81aed75e
......@@ -679,29 +679,26 @@ bool ThumbnailProtocol::createSubThumbnail(QImage& thumbnail, const QString& fil
if (thumbnail.isNull()) {
// no cached version is available, a new thumbnail must be created
QSaveFile thumbnailfile(thumbPath.absoluteFilePath(thumbName));
bool savedCorrectly = false;
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()));
savedCorrectly = thumbnail.save(&thumbnailfile, "PNG");
if (thumbnail.save(&thumbnailfile, "png")) {
thumbnailfile.commit();
}
}
} else {
return false;
}
if(savedCorrectly)
{
thumbnailfile.commit();
}
}
} 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