diff --git a/lib/libimhex/include/hex/providers/undo_redo/stack.hpp b/lib/libimhex/include/hex/providers/undo_redo/stack.hpp index 39021a549..3ab22cd2c 100644 --- a/lib/libimhex/include/hex/providers/undo_redo/stack.hpp +++ b/lib/libimhex/include/hex/providers/undo_redo/stack.hpp @@ -44,6 +44,12 @@ namespace hex::prv::undo { const std::vector> &getUndoneOperations() const { return this->m_redoStack; } + + void reset() { + this->m_undoStack.clear(); + this->m_redoStack.clear(); + } + private: [[nodiscard]] Operation* getLastOperation() const { return this->m_undoStack.back().get(); diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index 3007f964b..5d1d664ba 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -201,7 +201,7 @@ namespace hex::plugin::builtin { return { { "hex.builtin.provider.file.menu.open_folder"_lang, [this] { fs::openFolderWithSelectionExternal(this->m_path); } }, { "hex.builtin.provider.file.menu.open_file"_lang, [this] { fs::openFileExternal(this->m_path); } }, - { "hex.builtin.provider.file.menu.into_memory"_lang, [this] { this->convertToMemoryFile(); } } + { "hex.builtin.provider.file.menu.into_memory"_lang, [this] { this->convertToMemoryFile(); } } }; } @@ -313,7 +313,11 @@ namespace hex::plugin::builtin { } memoryProvider->markDirty(true); - ImHexApi::Provider::remove(this, false); + memoryProvider->getUndoStack().reset(); + + TaskManager::runWhenTasksFinished([this]{ + ImHexApi::Provider::remove(this, false); + }); }); } }