Skip to content

Commit

Permalink
fix: Don't delete font atlas after passing it to ImGui
Browse files Browse the repository at this point in the history
  • Loading branch information
WerWolv committed Jun 29, 2024
1 parent b94a428 commit 6fd594c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions plugins/fonts/source/font_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 6fd594c

Please sign in to comment.