From adbcc48de70e76806f87e5ade086de8bee5db595 Mon Sep 17 00:00:00 2001 From: SparkyTD <45818400+SparkyTD@users.noreply.github.com> Date: Tue, 7 May 2024 14:43:20 -0700 Subject: [PATCH] fix: Multiple file reload popups stacking on top of each other (#1654) ### Problem description This PR aims to address #1645 that caused the built in file provider's change monitor to trigger the notification popup dialog multiple times in a row after multiple external file changes. ### Implementation description I added an additional boolean field `m_changeEventAcknowledgementPending` that tracks whether there are any pending or unacknowledged change notification dialogs to prevent further dialogs from being opened. The flag is only reset to its initial value once the user has acknowledged the first `PopupQuestion` dialog. Since the file is reloaded only after the user clicks 'Yes', it is unnecessary to ensure that only the latest popup is acknowledged. --- .../include/content/providers/file_provider.hpp | 1 + .../source/content/providers/file_provider.cpp | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/plugins/builtin/include/content/providers/file_provider.hpp b/plugins/builtin/include/content/providers/file_provider.hpp index 25e39f5aa..9e737faf2 100644 --- a/plugins/builtin/include/content/providers/file_provider.hpp +++ b/plugins/builtin/include/content/providers/file_provider.hpp @@ -68,6 +68,7 @@ namespace hex::plugin::builtin { std::vector m_data; bool m_loadedIntoMemory = false; bool m_ignoreNextChangeEvent = false; + bool m_changeEventAcknowledgementPending = false; std::optional m_fileStats; diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index d8d3c128e..e1995c602 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -339,12 +339,21 @@ namespace hex::plugin::builtin { return; } + if(m_changeEventAcknowledgementPending) { + return; + } + + m_changeEventAcknowledgementPending = true; + ui::PopupQuestion::open("hex.builtin.provider.file.reload_changes"_lang, [this] { this->close(); (void)this->open(); getUndoStack().reapply(); + m_changeEventAcknowledgementPending = false; }, - []{}); + [this]{ + m_changeEventAcknowledgementPending = false; + }); }