fix: Crash when no plugins were loaded

This commit is contained in:
WerWolv
2025-02-01 18:08:47 +01:00
parent 0c6fa768ea
commit e9bf1a9f7a
2 changed files with 18 additions and 15 deletions

View File

@@ -340,14 +340,29 @@ namespace hex {
auto &currentFont = ImGui::GetIO().Fonts;
for (const auto &[name, font] : fontDefinitions) {
// If the texture for this atlas has been built already, don't do it again
if (font->ContainerAtlas->TexID != 0)
if (font == nullptr || font->ContainerAtlas->TexID != 0)
continue;
currentFont = font->ContainerAtlas;
ImGui_ImplOpenGL3_CreateFontsTexture();
}
currentFont = ImHexApi::Fonts::getFont("hex.fonts.font.default")->ContainerAtlas;
{
const auto &font = ImHexApi::Fonts::getFont("hex.fonts.font.default");
if (font == nullptr) {
const auto &io = ImGui::GetIO();
io.Fonts->Clear();
ImFontConfig cfg;
cfg.OversampleH = cfg.OversampleV = 1, cfg.PixelSnapH = true;
cfg.SizePixels = ImHexApi::Fonts::DefaultFontSize;
io.Fonts->AddFontDefault(&cfg);
ImGui_ImplOpenGL3_CreateFontsTexture();
} else {
currentFont = font->ContainerAtlas;
}
}
}
// Start new ImGui Frame