fix: Crash when no plugins could be loaded

This commit is contained in:
WerWolv
2025-07-10 16:36:37 +02:00
parent 3c16adf169
commit 82c318f91d
2 changed files with 13 additions and 5 deletions

View File

@@ -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;
}