Skip to content

Commit

Permalink
sokol_imgui.h: assert against texture leakage when calling simgui_cre…
Browse files Browse the repository at this point in the history
…ate_fonts_texture()
  • Loading branch information
floooh committed Mar 14, 2024
1 parent db32cf4 commit dd00e4d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions util/sokol_imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,9 @@ SOKOL_API_IMPL void simgui_setup(const simgui_desc_t* desc) {

SOKOL_API_IMPL void simgui_create_fonts_texture(const simgui_font_tex_desc_t* desc) {
SOKOL_ASSERT(desc);
SOKOL_ASSERT(SG_INVALID_ID == _simgui.font_smp.id);
SOKOL_ASSERT(SG_INVALID_ID == _simgui.font_img.id);
SOKOL_ASSERT(SIMGUI_INVALID_ID == _simgui.default_font.id);

#if defined(__cplusplus)
ImGuiIO* io = &ImGui::GetIO();
Expand Down Expand Up @@ -2430,6 +2433,9 @@ SOKOL_API_IMPL void simgui_destroy_fonts_texture(void) {
sg_destroy_sampler(_simgui.font_smp);
sg_destroy_image(_simgui.font_img);
simgui_destroy_image(_simgui.default_font);
_simgui.font_smp.id = SG_INVALID_ID;
_simgui.font_img.id = SG_INVALID_ID;
_simgui.default_font.id = SIMGUI_INVALID_ID;
}

SOKOL_API_IMPL void simgui_shutdown(void) {
Expand Down

0 comments on commit dd00e4d

Please sign in to comment.