From 949a1685f28b351c61f60fbe8acec0d7fe26a4b7 Mon Sep 17 00:00:00 2001 From: thedmd Date: Wed, 30 Jun 2021 17:35:50 +0200 Subject: [PATCH] WIP. DX9: Prevent use textures released in ImGui_ImplDX9_InvalidateDeviceObjects --- backends/imgui_impl_dx9.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/backends/imgui_impl_dx9.cpp b/backends/imgui_impl_dx9.cpp index e19497698c9f..65a467a22894 100644 --- a/backends/imgui_impl_dx9.cpp +++ b/backends/imgui_impl_dx9.cpp @@ -472,6 +472,9 @@ void ImGui_ImplDX9_UpdateTextures() { in_tex_data->EnsureFormat(ImTextureFormat_RGBA32); + if (current_texture != NULL && textures.find(current_texture) == textures.end()) + current_texture = NULL; // Make sure we do not access textures released by ImGui_ImplDX9_InvalidateDeviceObjects() + LPDIRECT3DTEXTURE9 new_texture = ImGui_ImplDX9_UpdateTexture(current_texture, in_tex_data); if (current_texture != nullptr && new_texture != current_texture) textures.find_erase_unsorted(current_texture);