mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-28 07:47:03 -05:00
impr: Make sure all views are closed before loading new workspace or layout
This commit is contained in:
@@ -71,6 +71,11 @@ namespace hex {
|
||||
*/
|
||||
static void lockLayout(bool locked);
|
||||
|
||||
/**
|
||||
* @brief Closes all views
|
||||
*/
|
||||
static void closeAllViews();
|
||||
|
||||
private:
|
||||
LayoutManager() = default;
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <imgui.h>
|
||||
#include <hex/api/content_registry.hpp>
|
||||
#include <hex/api/imhex_api.hpp>
|
||||
#include <hex/ui/view.hpp>
|
||||
|
||||
namespace hex {
|
||||
|
||||
@@ -64,16 +65,26 @@ namespace hex {
|
||||
return s_layouts;
|
||||
}
|
||||
|
||||
void LayoutManager::closeAllViews() {
|
||||
for (const auto &[name, view] : ContentRegistry::Views::impl::getEntries())
|
||||
view->getWindowOpenState() = false;
|
||||
}
|
||||
|
||||
void LayoutManager::process() {
|
||||
if (s_layoutPathToLoad.has_value()) {
|
||||
const auto pathString = wolv::util::toUTF8String(*s_layoutPathToLoad);
|
||||
|
||||
LayoutManager::closeAllViews();
|
||||
ImGui::LoadIniSettingsFromDisk(pathString.c_str());
|
||||
|
||||
s_layoutPathToLoad = std::nullopt;
|
||||
log::info("Loaded layout from {}", pathString);
|
||||
}
|
||||
|
||||
if (s_layoutStringToLoad.has_value()) {
|
||||
LayoutManager::closeAllViews();
|
||||
ImGui::LoadIniSettingsFromMemory(s_layoutStringToLoad->c_str());
|
||||
|
||||
s_layoutStringToLoad = std::nullopt;
|
||||
log::info("Loaded layout from string");
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ namespace hex {
|
||||
if (s_previousWorkspace != s_workspaces.end())
|
||||
exportToFile(s_previousWorkspace->second.path, s_previousWorkspace->first);
|
||||
|
||||
LayoutManager::closeAllViews();
|
||||
ImGui::LoadIniSettingsFromMemory(s_currentWorkspace->second.layout.c_str());
|
||||
|
||||
s_previousWorkspace = s_currentWorkspace;
|
||||
|
||||
Reference in New Issue
Block a user