mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-20 23:06:36 +00:00
Viewport: Fix an issue introduced on ~August 16, which would assert when viewport are disabled. Also made the DestroyPlatformWindow process more sturdy. (#1542)
This commit is contained in:
parent
f29b3b4033
commit
85a3fb3bef
13
imgui.cpp
13
imgui.cpp
@ -7656,17 +7656,20 @@ void ImGui::DestroyPlatformWindow(ImGuiViewportP* viewport)
|
|||||||
g.PlatformIO.Renderer_DestroyWindow(viewport);
|
g.PlatformIO.Renderer_DestroyWindow(viewport);
|
||||||
if (viewport->CreatedPlatformWindow && g.PlatformIO.Platform_DestroyWindow)
|
if (viewport->CreatedPlatformWindow && g.PlatformIO.Platform_DestroyWindow)
|
||||||
g.PlatformIO.Platform_DestroyWindow(viewport);
|
g.PlatformIO.Platform_DestroyWindow(viewport);
|
||||||
viewport->CreatedPlatformWindow = false;
|
|
||||||
IM_ASSERT(viewport->RendererUserData == NULL);
|
IM_ASSERT(viewport->RendererUserData == NULL);
|
||||||
IM_ASSERT(viewport->PlatformUserData == NULL && viewport->PlatformHandle == NULL);
|
IM_ASSERT(viewport->PlatformUserData == NULL);
|
||||||
|
viewport->PlatformHandle = NULL;
|
||||||
|
viewport->RendererUserData = viewport->PlatformHandle = NULL;
|
||||||
|
viewport->CreatedPlatformWindow = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui::DestroyPlatformWindows()
|
void ImGui::DestroyPlatformWindows()
|
||||||
{
|
{
|
||||||
// We call the destroy window on the main viewport (index 0) to give a chance to the back-end to clear any data
|
// We call the destroy window on the main viewport (index 0) to give a chance to the back-end to clear any data
|
||||||
// have stored in e.g. PlatformHandle.
|
// have stored in e.g. PlatformUserData, RendererUserData. It can be convenient for the platform back-end code to
|
||||||
// It is expected that the back-end stored a flag to remember that it doesn't own the window created for the
|
// store something in the main viewport, in order for e.g. the mouse handling code to work in a more generic manner.
|
||||||
// main viewport, and won't destroy the underlying platform/renderer data.
|
// It is expected that the back-end can handle calls to Renderer_DestroyWindow/Platform_DestroyWindow without
|
||||||
|
// crashing if it doesn't have data stored.
|
||||||
ImGuiContext& g = *GImGui;
|
ImGuiContext& g = *GImGui;
|
||||||
for (int i = 0; i < g.Viewports.Size; i++)
|
for (int i = 0; i < g.Viewports.Size; i++)
|
||||||
if (g.Viewports[i]->CreatedPlatformWindow)
|
if (g.Viewports[i]->CreatedPlatformWindow)
|
||||||
|
Loading…
Reference in New Issue
Block a user