From 8385b88ce8f60ed19d7a4a4b42bd4107c0b17419 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 5 Dec 2021 22:09:43 +0100 Subject: [PATCH] sys: Clean up properly after file is closed Addresses another issue in #362 --- source/views/view_bookmarks.cpp | 5 +++++ source/views/view_disassembler.cpp | 5 +++++ source/views/view_information.cpp | 5 +++++ source/views/view_pattern_editor.cpp | 6 ++++++ source/views/view_strings.cpp | 5 +++++ 5 files changed, 26 insertions(+) diff --git a/source/views/view_bookmarks.cpp b/source/views/view_bookmarks.cpp index 23f21f224..f96bf79a9 100644 --- a/source/views/view_bookmarks.cpp +++ b/source/views/view_bookmarks.cpp @@ -37,12 +37,17 @@ namespace hex { EventManager::subscribe(this, []{ ProjectFile::setBookmarks(SharedData::bookmarkEntries); }); + + EventManager::subscribe(this, []{ + ImHexApi::Bookmarks::getEntries().clear(); + }); } ViewBookmarks::~ViewBookmarks() { EventManager::unsubscribe(this); EventManager::unsubscribe(this); EventManager::unsubscribe(this); + EventManager::unsubscribe(this); } void ViewBookmarks::drawContent() { diff --git a/source/views/view_disassembler.cpp b/source/views/view_disassembler.cpp index 448adda4b..90cbb1649 100644 --- a/source/views/view_disassembler.cpp +++ b/source/views/view_disassembler.cpp @@ -27,11 +27,16 @@ namespace hex { } } }); + + EventManager::subscribe(this, [this]{ + this->m_disassembly.clear(); + }); } ViewDisassembler::~ViewDisassembler() { EventManager::unsubscribe(this); EventManager::unsubscribe(this); + EventManager::unsubscribe(this); } void ViewDisassembler::disassemble() { diff --git a/source/views/view_information.cpp b/source/views/view_information.cpp index 28714ed23..adadee07f 100644 --- a/source/views/view_information.cpp +++ b/source/views/view_information.cpp @@ -39,11 +39,16 @@ namespace hex { if (this->m_blockSize != 0) this->m_entropyHandlePosition = region.address / this->m_blockSize; }); + + EventManager::subscribe(this, [this]{ + this->m_dataValid = false; + }); } ViewInformation::~ViewInformation() { EventManager::unsubscribe(this); EventManager::unsubscribe(this); + EventManager::unsubscribe(this); } static float calculateEntropy(std::array &valueCounts, size_t numBytes) { diff --git a/source/views/view_pattern_editor.cpp b/source/views/view_pattern_editor.cpp index b0751680b..26cfdeb69 100644 --- a/source/views/view_pattern_editor.cpp +++ b/source/views/view_pattern_editor.cpp @@ -152,6 +152,11 @@ namespace hex { } }); + EventManager::subscribe(this, [this]{ + this->m_textEditor.SetText(""); + this->m_patternLanguageRuntime->abort(); + }); + /* Settings */ { @@ -181,6 +186,7 @@ namespace hex { EventManager::unsubscribe(this); EventManager::unsubscribe(this); EventManager::unsubscribe(this); + EventManager::unsubscribe(this); } void ViewPatternEditor::drawMenu() { diff --git a/source/views/view_strings.cpp b/source/views/view_strings.cpp index 195d84d64..20f6af9ca 100644 --- a/source/views/view_strings.cpp +++ b/source/views/view_strings.cpp @@ -21,10 +21,15 @@ namespace hex { this->m_filter.reserve(0xFFFF); std::memset(this->m_filter.data(), 0x00, this->m_filter.capacity()); + + EventManager::subscribe(this, [this]{ + this->m_foundStrings.clear(); + }); } ViewStrings::~ViewStrings() { EventManager::unsubscribe(this); + EventManager::unsubscribe(this); } std::string readString(const FoundString &foundString) {