Commit a585df06 authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark
Browse files

Don't fill disk with thumbnails if thumbnail saving is turned off

Even if "low resource usage mode" is turned on, which says it avoids
storing thumbnails to disk to save space, it still stores thumbnails to
disk. It just deletes _all_ thumbnails afterwards (even those not from
gwenview itself).

This was also kind of racy, because thumbnailwriter could still be
running, but the folders would be deleted, so it spammed a ton of error
messages.

Test Plan:
Doesn't store thumbnails when it shouldn't anymore, doesn't
delete thumbnails from other applications nor the thumbnail folders,
thumbnailwriter doesn't spaz out during exit, stores thumbnails when it
should.

Differential Revision: https://phabricator.kde.org/D28375
parent 662c29b3
......@@ -48,7 +48,7 @@
<item row="1" column="1">
<widget class="QLabel" name="cacheHelpLabel">
<property name="text">
<string>Enable this option if you do not have a lot of disk space. This will avoid storing thumbnails on disk and will prefer embedded thumbnails of lower quality that are faster to load, if available.&lt;br/&gt;&lt;br/&gt;&lt;em&gt;Be careful:&lt;/em&gt; this will delete the folder named &lt;filename&gt;thumbnails&lt;/filename&gt; in your &lt;filename&gt;.cache&lt;/filename&gt; folder, removing all thumbnails previously generated by Gwenview and other applications.</string>
<string>Enable this option if you do not have a lot of disk space. This will avoid storing thumbnails on disk and will prefer embedded thumbnails of lower quality that are faster to load, if available.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
......
......@@ -927,12 +927,6 @@ MainWindow::MainWindow()
MainWindow::~MainWindow()
{
if (GwenviewConfig::lowResourceUsageMode()) {
QDir dir(ThumbnailProvider::thumbnailBaseDir());
if (dir.exists()) {
dir.removeRecursively();
}
}
delete d->mThumbnailProvider;
delete d;
}
......
......@@ -22,10 +22,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Cambridge, MA 02110-1301, USA
#include "thumbnailwriter.h"
// Local
#include "gwenview_lib_debug.h"
#include "gwenviewconfig.h"
// Qt
#include <QImage>
#include "gwenview_lib_debug.h"
#include <QTemporaryFile>
namespace Gwenview
......@@ -42,6 +43,10 @@ namespace Gwenview
static void storeThumbnailToDiskCache(const QString& path, const QImage& image)
{
if (GwenviewConfig::lowResourceUsageMode()) {
return;
}
LOG(path);
QTemporaryFile tmp(path + QStringLiteral(".gwenview.tmpXXXXXX.png"));
if (!tmp.open()) {
......@@ -59,6 +64,10 @@ static void storeThumbnailToDiskCache(const QString& path, const QImage& image)
void ThumbnailWriter::queueThumbnail(const QString& path, const QImage& image)
{
if (GwenviewConfig::lowResourceUsageMode()) {
return;
}
LOG(path);
QMutexLocker locker(&mMutex);
mCache.insert(path, image);
......
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