diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index cb15a51c4..1cf26c427 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -1030,7 +1030,7 @@ namespace hex { void Font::push(float size) const { auto font = getFont(m_fontName); - if (size <= 0.0F) { + if (size <= 0.0F && font != nullptr) { size = font->LegacySize; } @@ -1116,7 +1116,12 @@ namespace hex { } ImFont* getFont(const UnlocalizedString &fontName) { - return (*impl::s_fontDefinitions)[fontName]; + auto it = impl::s_fontDefinitions->find(fontName); + + if (it == impl::s_fontDefinitions->end()) + return ImGui::GetDefaultFont(); + else + return it->second; } void setDefaultFont(const Font& font) { @@ -1124,6 +1129,10 @@ namespace hex { } const Font& getDefaultFont() { + if (*impl::s_defaultFont == nullptr) { + static Font emptyFont(""); + return emptyFont; + } return **impl::s_defaultFont; } diff --git a/main/gui/source/window/window.cpp b/main/gui/source/window/window.cpp index 2d67db0bb..85fc308f2 100644 --- a/main/gui/source/window/window.cpp +++ b/main/gui/source/window/window.cpp @@ -347,9 +347,6 @@ namespace hex { } void Window::frameBegin() { - // Run all deferred calls - TaskManager::runDeferredCalls(); - ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); @@ -364,6 +361,8 @@ namespace hex { ImGuiTestEngine_ShowTestEngineWindows(m_testEngine, nullptr); #endif + // Run all deferred calls + TaskManager::runDeferredCalls(); TutorialManager::drawTutorial();