From 6163f6c4a0ec4afee6fc5a665999e2976bc80b0d Mon Sep 17 00:00:00 2001 From: WerWolv Date: Wed, 20 Dec 2023 16:31:31 +0100 Subject: [PATCH] fix: ImHex crashing when no fonts were loaded --- main/gui/source/window/window.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index 907170067..4fb304f45 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -92,7 +92,9 @@ namespace hex { RequestOpenPopup::unsubscribe(this); WorkspaceManager::exportToFile(); - ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.curr_workspace", WorkspaceManager::getCurrentWorkspace()->first); + + if (auto workspace = WorkspaceManager::getCurrentWorkspace(); workspace != WorkspaceManager::getWorkspaces().end()) + ContentRegistry::Settings::write("hex.builtin.setting.general", "hex.builtin.setting.general.curr_workspace", workspace->first); this->exitImGui(); this->exitGLFW(); @@ -1166,6 +1168,13 @@ namespace hex { auto fonts = ImHexApi::Fonts::getFontAtlas(); + if (fonts == nullptr) { + fonts = IM_NEW(ImFontAtlas)(); + + fonts->AddFontDefault(); + fonts->Build(); + } + // Initialize ImGui and all other ImGui extensions GImGui = ImGui::CreateContext(fonts); GImPlot = ImPlot::CreateContext();