mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 09:27:00 +00:00
Viewport: Give a chance to platform and renderer to actually destroy their data. Otherwise the regular ImplXXX_Shutdown + following by DestroyContext() order fails to fullifl this. (#1542)
This commit is contained in:
parent
cab41d954e
commit
e026c8d3b7
@ -611,6 +611,7 @@ void ImGui_ImplDX10_InitPlatformInterface()
|
|||||||
|
|
||||||
void ImGui_ImplDX10_ShutdownPlatformInterface()
|
void ImGui_ImplDX10_ShutdownPlatformInterface()
|
||||||
{
|
{
|
||||||
|
ImGui::DestroyViewportsRendererData(ImGui::GetCurrentContext());
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
memset(&io.RendererInterface, 0, sizeof(io.RendererInterface));
|
memset(&io.RendererInterface, 0, sizeof(io.RendererInterface));
|
||||||
}
|
}
|
||||||
|
@ -619,6 +619,7 @@ void ImGui_ImplDX11_InitPlatformInterface()
|
|||||||
|
|
||||||
void ImGui_ImplDX11_ShutdownPlatformInterface()
|
void ImGui_ImplDX11_ShutdownPlatformInterface()
|
||||||
{
|
{
|
||||||
|
ImGui::DestroyViewportsRendererData(ImGui::GetCurrentContext());
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
memset(&io.RendererInterface, 0, sizeof(io.RendererInterface));
|
memset(&io.RendererInterface, 0, sizeof(io.RendererInterface));
|
||||||
}
|
}
|
||||||
|
@ -763,6 +763,7 @@ void ImGui_ImplDX12_InitPlatformInterface()
|
|||||||
|
|
||||||
void ImGui_ImplDX12_ShutdownPlatformInterface()
|
void ImGui_ImplDX12_ShutdownPlatformInterface()
|
||||||
{
|
{
|
||||||
|
ImGui::DestroyViewportsRendererData(ImGui::GetCurrentContext());
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
memset(&io.RendererInterface, 0, sizeof(io.RendererInterface));
|
memset(&io.RendererInterface, 0, sizeof(io.RendererInterface));
|
||||||
}
|
}
|
||||||
|
@ -327,6 +327,7 @@ void ImGui_ImplOpenGL3_InitPlatformInterface()
|
|||||||
|
|
||||||
void ImGui_ImplOpenGL3_ShutdownPlatformInterface()
|
void ImGui_ImplOpenGL3_ShutdownPlatformInterface()
|
||||||
{
|
{
|
||||||
|
ImGui::DestroyViewportsRendererData(ImGui::GetCurrentContext());
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
memset(&io.RendererInterface, 0, sizeof(io.RendererInterface));
|
memset(&io.RendererInterface, 0, sizeof(io.RendererInterface));
|
||||||
}
|
}
|
||||||
|
23
imgui.cpp
23
imgui.cpp
@ -3909,6 +3909,20 @@ void ImGui::Initialize(ImGuiContext* context)
|
|||||||
g.Initialized = true;
|
g.Initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGui::DestroyViewportsPlaformData(ImGuiContext* context)
|
||||||
|
{
|
||||||
|
if (context->IO.PlatformInterface.DestroyViewport)
|
||||||
|
for (int i = 0; i < context->Viewports.Size; i++)
|
||||||
|
context->IO.PlatformInterface.DestroyViewport(context->Viewports[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ImGui::DestroyViewportsRendererData(ImGuiContext* context)
|
||||||
|
{
|
||||||
|
if (context->IO.RendererInterface.DestroyViewport)
|
||||||
|
for (int i = 0; i < context->Viewports.Size; i++)
|
||||||
|
context->IO.RendererInterface.DestroyViewport(context->Viewports[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// This function is merely here to free heap allocations.
|
// This function is merely here to free heap allocations.
|
||||||
void ImGui::Shutdown(ImGuiContext* context)
|
void ImGui::Shutdown(ImGuiContext* context)
|
||||||
{
|
{
|
||||||
@ -3945,16 +3959,11 @@ void ImGui::Shutdown(ImGuiContext* context)
|
|||||||
g.OpenPopupStack.clear();
|
g.OpenPopupStack.clear();
|
||||||
g.CurrentPopupStack.clear();
|
g.CurrentPopupStack.clear();
|
||||||
g.MouseViewport = g.MouseLastHoveredViewport = NULL;
|
g.MouseViewport = g.MouseLastHoveredViewport = NULL;
|
||||||
|
DestroyViewportsPlaformData(context);
|
||||||
|
DestroyViewportsRendererData(context);
|
||||||
for (int i = 0; i < g.Viewports.Size; i++)
|
for (int i = 0; i < g.Viewports.Size; i++)
|
||||||
{
|
{
|
||||||
ImGuiViewport* viewport = g.Viewports[i];
|
ImGuiViewport* viewport = g.Viewports[i];
|
||||||
if (!(viewport->Flags & ImGuiViewportFlags_MainViewport)) // FIXME-VIEWPORT
|
|
||||||
{
|
|
||||||
if (g.IO.RendererInterface.DestroyViewport)
|
|
||||||
g.IO.RendererInterface.DestroyViewport(viewport);
|
|
||||||
if (g.IO.PlatformInterface.DestroyViewport)
|
|
||||||
g.IO.PlatformInterface.DestroyViewport(viewport);
|
|
||||||
}
|
|
||||||
viewport->PlatformUserData = viewport->PlatformHandle = viewport->RendererUserData = NULL;
|
viewport->PlatformUserData = viewport->PlatformHandle = viewport->RendererUserData = NULL;
|
||||||
IM_DELETE(viewport);
|
IM_DELETE(viewport);
|
||||||
}
|
}
|
||||||
|
@ -1093,6 +1093,8 @@ namespace ImGui
|
|||||||
IMGUI_API ImGuiViewport* FindViewportByPlatformHandle(void* platform_handle);
|
IMGUI_API ImGuiViewport* FindViewportByPlatformHandle(void* platform_handle);
|
||||||
IMGUI_API void SetNextWindowViewport(ImGuiID id);
|
IMGUI_API void SetNextWindowViewport(ImGuiID id);
|
||||||
IMGUI_API void ShowViewportThumbnails();
|
IMGUI_API void ShowViewportThumbnails();
|
||||||
|
IMGUI_API void DestroyViewportsPlaformData(ImGuiContext* context);
|
||||||
|
IMGUI_API void DestroyViewportsRendererData(ImGuiContext* context);
|
||||||
|
|
||||||
IMGUI_API void MarkIniSettingsDirty();
|
IMGUI_API void MarkIniSettingsDirty();
|
||||||
IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name);
|
IMGUI_API ImGuiSettingsHandler* FindSettingsHandler(const char* type_name);
|
||||||
|
Loading…
Reference in New Issue
Block a user