From 51c200ac0d5a8eaf4eb9eacc84ddcc5dbb3b5a9e Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 2 Jun 2017 11:23:35 +0200 Subject: [PATCH] Examples: DirectX9: Clarified texture release code (#1163) --- examples/directx9_example/imgui_impl_dx9.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/examples/directx9_example/imgui_impl_dx9.cpp b/examples/directx9_example/imgui_impl_dx9.cpp index 93472f65..691cb464 100644 --- a/examples/directx9_example/imgui_impl_dx9.cpp +++ b/examples/directx9_example/imgui_impl_dx9.cpp @@ -311,12 +311,13 @@ void ImGui_ImplDX9_InvalidateDeviceObjects() g_pIB->Release(); g_pIB = NULL; } - if (LPDIRECT3DTEXTURE9 tex = (LPDIRECT3DTEXTURE9)ImGui::GetIO().Fonts->TexID) - { - tex->Release(); - ImGui::GetIO().Fonts->TexID = 0; - } + + // At this point note that we set ImGui::GetIO().Fonts->TexID to be == g_FontTexture, so clear both. + if (g_FontTexture) + g_FontTexture->Release(); g_FontTexture = NULL; + ImGuiIO& io = ImGui::GetIO(); + io.Fonts->TexID = NULL; } void ImGui_ImplDX9_NewFrame()