fix: Don't delete font atlas after passing it to ImGui

This commit is contained in:
WerWolv 2024-06-29 20:26:46 +02:00
parent b94a4288bf
commit 6fd594c1f4
1 changed files with 6 additions and 3 deletions

View File

@ -152,8 +152,11 @@ namespace hex::fonts {
return m_fontAtlas->Build();
}
[[nodiscard]] ImFontAtlas* getAtlas() const {
return m_fontAtlas;
[[nodiscard]] ImFontAtlas* takeAtlas() {
auto result = m_fontAtlas;
m_fontAtlas = nullptr;
return result;
}
float calculateFontDescend(const ImHexApi::Fonts::Font &font, float fontSize) const {
@ -331,7 +334,7 @@ namespace hex::fonts {
const bool result = fontAtlas.build();
if (result) {
// Set the font atlas if the build was successful
ImHexApi::Fonts::impl::setFontAtlas(fontAtlas.getAtlas());
ImHexApi::Fonts::impl::setFontAtlas(fontAtlas.takeAtlas());
return true;
}