Commit dab1e85d authored by Halla Rempt's avatar Halla Rempt
Browse files

Only try to load a thumbnail for a recent file item that still exists

BUG:401939
parent 95b09eaf
......@@ -20,6 +20,8 @@
#include "KisWelcomePageWidget.h"
#include <QDebug>
#include <QDesktopServices>
#include <QFileInfo>
#include "kis_action_manager.h"
#include "kactioncollection.h"
#include "kis_action.h"
......@@ -205,29 +207,31 @@ void KisWelcomePageWidget::populateRecentDocuments()
recentItem->setIcon(m_thumbnailMap[recentFileUrlPath]);
}
else {
if (recentFileUrlPath.endsWith("ora") || recentFileUrlPath.endsWith("kra")) {
QScopedPointer<KoStore> store(KoStore::createStore(QUrl(recentFileUrlPath), KoStore::Read));
if (store) {
if (store->open(QString("Thumbnails/thumbnail.png"))
|| store->open(QString("preview.png"))) {
QByteArray bytes = store->read(store->size());
store->close();
QImage img;
img.loadFromData(bytes);
img.setDevicePixelRatio(devicePixelRatioF());
recentItem->setIcon(QIcon(QPixmap::fromImage(img)));
if (QFileInfo(recentFileUrlPath).exists()) {
if (recentFileUrlPath.endsWith("ora") || recentFileUrlPath.endsWith("kra")) {
QScopedPointer<KoStore> store(KoStore::createStore(QUrl(recentFileUrlPath), KoStore::Read));
if (store) {
if (store->open(QString("Thumbnails/thumbnail.png"))
|| store->open(QString("preview.png"))) {
QByteArray bytes = store->read(store->size());
store->close();
QImage img;
img.loadFromData(bytes);
img.setDevicePixelRatio(devicePixelRatioF());
recentItem->setIcon(QIcon(QPixmap::fromImage(img)));
}
}
}
}
else {
QImage img(QUrl(recentFileUrlPath).toLocalFile());
img.setDevicePixelRatio(devicePixelRatioF());
if (!img.isNull()) {
recentItem->setIcon(QIcon(QPixmap::fromImage(img.scaledToWidth(48))));
else {
QImage img(QUrl(recentFileUrlPath).toLocalFile());
img.setDevicePixelRatio(devicePixelRatioF());
if (!img.isNull()) {
recentItem->setIcon(QIcon(QPixmap::fromImage(img.scaledToWidth(48))));
}
}
m_thumbnailMap[recentFileUrlPath] = recentItem->icon();
}
m_thumbnailMap[recentFileUrlPath] = recentItem->icon();
}
// set the recent object with the data
......
Supports Markdown
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