Viewport: DestroyPlatformWindow() skips calling user function if PlatformWindowCreated is set. + Clarified comment about implicit Debug viewport which may be hogging a viewport.

This commit is contained in:
omar 2019-03-13 11:27:30 +01:00
parent e7dca4fec2
commit c3f20f6b81

View File

@ -10446,7 +10446,8 @@ void ImGui::UpdatePlatformWindows()
{
ImGuiViewportP* viewport = g.Viewports[i];
// Destroy platform window if the viewport hasn't been submitted or if it is hosting a hidden window (the implicit/fallback Debug window will be registered its viewport then be disabled)
// Destroy platform window if the viewport hasn't been submitted or if it is hosting a hidden window
// (the implicit/fallback Debug##Default window will be registering its viewport then be disabled, causing a dummy DestroyPlatformWindow to be made each frame)
bool destroy_platform_window = false;
destroy_platform_window |= (viewport->LastFrameActive < g.FrameCount - 1);
destroy_platform_window |= (viewport->Window && !IsWindowActiveAndVisible(viewport->Window));
@ -10628,15 +10629,20 @@ static void ImGui::UpdateViewportPlatformMonitor(ImGuiViewportP* viewport)
void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport)
{
ImGuiContext& g = *GImGui;
if (g.PlatformIO.Renderer_DestroyWindow)
g.PlatformIO.Renderer_DestroyWindow(viewport);
if (g.PlatformIO.Platform_DestroyWindow)
g.PlatformIO.Platform_DestroyWindow(viewport);
IM_ASSERT(viewport->RendererUserData == NULL);
IM_ASSERT(viewport->PlatformUserData == NULL);
viewport->PlatformHandle = NULL;
viewport->RendererUserData = viewport->PlatformHandle = NULL;
viewport->PlatformWindowCreated = false;
if (viewport->PlatformWindowCreated)
{
if (g.PlatformIO.Renderer_DestroyWindow)
g.PlatformIO.Renderer_DestroyWindow(viewport);
if (g.PlatformIO.Platform_DestroyWindow)
g.PlatformIO.Platform_DestroyWindow(viewport);
IM_ASSERT(viewport->RendererUserData == NULL && viewport->PlatformUserData == NULL);
viewport->PlatformWindowCreated = false;
}
else
{
IM_ASSERT(viewport->RendererUserData == NULL && viewport->PlatformUserData == NULL && viewport->PlatformHandle == NULL);
}
viewport->RendererUserData = viewport->PlatformUserData = viewport->PlatformHandle = NULL;
viewport->ClearRequestFlags();
}