From f85c41a0d650e52d4fd14c582f835becf1d5ddf1 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Wed, 18 May 2022 10:57:25 -0700 Subject: [PATCH] cache: warn user in UI when disk cache is full --- app/core.cpp | 19 ++++++++++++++++++- app/core.h | 4 ++++ app/render/diskmanager.cpp | 11 ++++++++++- 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/app/core.cpp b/app/core.cpp index 5f00a7b69..f5bea63d4 100644 --- a/app/core.cpp +++ b/app/core.cpp @@ -87,7 +87,8 @@ Core::Core(const CoreParams& params) : addable_object_(Tool::kAddableEmpty), snapping_(true), core_params_(params), - pixel_sampling_users_(0) + pixel_sampling_users_(0), + shown_cache_full_warning_(false) { // Store reference to this object, making the assumption that Core will only ever be made in // main(). This will obviously break if not. @@ -1297,6 +1298,22 @@ void Core::RequestPixelSamplingInViewers(bool e) } } +void Core::WarnCacheFull() +{ + if (!shown_cache_full_warning_ && main_window_) { + shown_cache_full_warning_ = true; + + QMessageBox::warning(main_window_, tr("Disk Cache Full"), + tr("The disk cache is currently full and Olive is having to delete old " + "frames to keep it within the limits set in the Disk preferences. This " + "will result in SIGNIFICANTLY reduced cache performance.\n\n" + "To remedy this, please do one of the following:\n\n" + "1. Manually clear the disk cache in Disk preferences.\n" + "2. Increase the maximum disk cache size in Disk preferences.\n" + "3. Reduce usage of the disk cache (e.g. disable auto-cache or only cache specific sections of your sequence).")); + } +} + bool Core::SaveProjectAs(Project* p) { QFileDialog fd(main_window_, tr("Save Project As")); diff --git a/app/core.h b/app/core.h index b12000c14..429fbb549 100644 --- a/app/core.h +++ b/app/core.h @@ -441,6 +441,8 @@ public slots: void RequestPixelSamplingInViewers(bool e); + void WarnCacheFull(); + signals: /** * @brief Signal emitted when a project is opened @@ -621,6 +623,8 @@ private: */ int pixel_sampling_users_; + bool shown_cache_full_warning_; + private slots: void SaveAutorecovery(); diff --git a/app/render/diskmanager.cpp b/app/render/diskmanager.cpp index 1d2c00d20..5cd8c0a00 100644 --- a/app/render/diskmanager.cpp +++ b/app/render/diskmanager.cpp @@ -353,7 +353,16 @@ bool DiskCacheFolder::DeleteLeastRecent() } } - return DeleteFileInternal(hash_to_delete); + bool e = DeleteFileInternal(hash_to_delete); + + if (e) { + Core::instance()->WarnCacheFull(); + } + + return e; + } else { + return false; + } } void DiskCacheFolder::CloseCacheFolder()