fix: Crash when no plugins were loaded
This commit is contained in:
parent
0c6fa768ea
commit
e9bf1a9f7a
@ -529,19 +529,7 @@ namespace hex::init {
|
|||||||
cfg.OversampleH = cfg.OversampleV = 1, cfg.PixelSnapH = true;
|
cfg.OversampleH = cfg.OversampleV = 1, cfg.PixelSnapH = true;
|
||||||
cfg.SizePixels = ImHexApi::Fonts::DefaultFontSize;
|
cfg.SizePixels = ImHexApi::Fonts::DefaultFontSize;
|
||||||
io.Fonts->AddFontDefault(&cfg);
|
io.Fonts->AddFontDefault(&cfg);
|
||||||
|
ImGui_ImplOpenGL3_CreateFontsTexture();
|
||||||
std::uint8_t *px;
|
|
||||||
int w, h;
|
|
||||||
io.Fonts->GetTexDataAsAlpha8(&px, &w, &h);
|
|
||||||
|
|
||||||
// Create new font atlas
|
|
||||||
GLuint tex;
|
|
||||||
glGenTextures(1, &tex);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, tex);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, w, h, 0, GL_ALPHA, GL_UNSIGNED_BYTE, px);
|
|
||||||
io.Fonts->SetTexID(tex);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't save window settings for the splash screen
|
// Don't save window settings for the splash screen
|
||||||
|
@ -340,14 +340,29 @@ namespace hex {
|
|||||||
auto ¤tFont = ImGui::GetIO().Fonts;
|
auto ¤tFont = ImGui::GetIO().Fonts;
|
||||||
for (const auto &[name, font] : fontDefinitions) {
|
for (const auto &[name, font] : fontDefinitions) {
|
||||||
// If the texture for this atlas has been built already, don't do it again
|
// 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;
|
continue;
|
||||||
|
|
||||||
currentFont = font->ContainerAtlas;
|
currentFont = font->ContainerAtlas;
|
||||||
ImGui_ImplOpenGL3_CreateFontsTexture();
|
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
|
// Start new ImGui Frame
|
||||||
|
Loading…
x
Reference in New Issue
Block a user