diff --git a/examples/imgui_impl_dx10.cpp b/examples/imgui_impl_dx10.cpp index 8d2c647..235428f 100644 --- a/examples/imgui_impl_dx10.cpp +++ b/examples/imgui_impl_dx10.cpp @@ -500,6 +500,7 @@ } if (pDXGIDevice) pDXGIDevice->Release(); if (pDXGIAdapter) pDXGIAdapter->Release(); + g_pd3dDevice->AddRef(); return true; } @@ -508,7 +509,7 @@ { ImGui_ImplDX10_InvalidateDeviceObjects(); if (g_pFactory) { g_pFactory->Release(); g_pFactory = NULL; } - g_pd3dDevice = NULL; + if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } } void ImGui_ImplDX10_NewFrame() diff --git a/examples/imgui_impl_dx10.cpp b/examples/imgui_impl_dx10.cpp index 8d2c647..235428f 100644 --- a/examples/imgui_impl_dx10.cpp +++ b/examples/imgui_impl_dx10.cpp @@ -500,6 +500,7 @@ } if (pDXGIDevice) pDXGIDevice->Release(); if (pDXGIAdapter) pDXGIAdapter->Release(); + g_pd3dDevice->AddRef(); return true; } @@ -508,7 +509,7 @@ { ImGui_ImplDX10_InvalidateDeviceObjects(); if (g_pFactory) { g_pFactory->Release(); g_pFactory = NULL; } - g_pd3dDevice = NULL; + if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } } void ImGui_ImplDX10_NewFrame() diff --git a/examples/imgui_impl_dx11.cpp b/examples/imgui_impl_dx11.cpp index 9a44d6a..18c32e6 100644 --- a/examples/imgui_impl_dx11.cpp +++ b/examples/imgui_impl_dx11.cpp @@ -508,6 +508,8 @@ } if (pDXGIDevice) pDXGIDevice->Release(); if (pDXGIAdapter) pDXGIAdapter->Release(); + g_pd3dDevice->AddRef(); + g_pd3dDeviceContext->AddRef(); return true; } @@ -516,8 +518,8 @@ { ImGui_ImplDX11_InvalidateDeviceObjects(); if (g_pFactory) { g_pFactory->Release(); g_pFactory = NULL; } - g_pd3dDevice = NULL; - g_pd3dDeviceContext = NULL; + if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } + if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = NULL; } } void ImGui_ImplDX11_NewFrame() diff --git a/examples/imgui_impl_dx10.cpp b/examples/imgui_impl_dx10.cpp index 8d2c647..235428f 100644 --- a/examples/imgui_impl_dx10.cpp +++ b/examples/imgui_impl_dx10.cpp @@ -500,6 +500,7 @@ } if (pDXGIDevice) pDXGIDevice->Release(); if (pDXGIAdapter) pDXGIAdapter->Release(); + g_pd3dDevice->AddRef(); return true; } @@ -508,7 +509,7 @@ { ImGui_ImplDX10_InvalidateDeviceObjects(); if (g_pFactory) { g_pFactory->Release(); g_pFactory = NULL; } - g_pd3dDevice = NULL; + if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } } void ImGui_ImplDX10_NewFrame() diff --git a/examples/imgui_impl_dx11.cpp b/examples/imgui_impl_dx11.cpp index 9a44d6a..18c32e6 100644 --- a/examples/imgui_impl_dx11.cpp +++ b/examples/imgui_impl_dx11.cpp @@ -508,6 +508,8 @@ } if (pDXGIDevice) pDXGIDevice->Release(); if (pDXGIAdapter) pDXGIAdapter->Release(); + g_pd3dDevice->AddRef(); + g_pd3dDeviceContext->AddRef(); return true; } @@ -516,8 +518,8 @@ { ImGui_ImplDX11_InvalidateDeviceObjects(); if (g_pFactory) { g_pFactory->Release(); g_pFactory = NULL; } - g_pd3dDevice = NULL; - g_pd3dDeviceContext = NULL; + if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } + if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = NULL; } } void ImGui_ImplDX11_NewFrame() diff --git a/examples/imgui_impl_dx9.cpp b/examples/imgui_impl_dx9.cpp index f375c39..fd4522c 100644 --- a/examples/imgui_impl_dx9.cpp +++ b/examples/imgui_impl_dx9.cpp @@ -219,13 +219,14 @@ io.BackendRendererName = "imgui_impl_dx9"; g_pd3dDevice = device; + g_pd3dDevice->AddRef(); return true; } void ImGui_ImplDX9_Shutdown() { ImGui_ImplDX9_InvalidateDeviceObjects(); - g_pd3dDevice = NULL; + if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } } static bool ImGui_ImplDX9_CreateFontsTexture()