mirror of
https://github.com/ocornut/imgui.git
synced 2026-11-27 00:53:33 +00:00
Docking+Viewports: NULL Viewport crash in UpdateTryMergeWindowIntoHostViewport() when re-opening a window docked in a hidden floating node #9631
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#9631
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version/Branch of Dear ImGui:
1.92.4, docking
Back-ends:
imgui_impl_win32.cpp + imgui_impl_opengl3.cpp (multi-viewport renderer hooks as in example_win32_opengl3)
Compiler, OS:
Windows 11 24H2 (build 26100) + MSVC 2022 17.14 (19.44.35219)
Full config/build information:
Details:
My Issue/Question:
Access violation reading 0x70 (
ImGuiViewportP::Window) inSetWindowViewport()withwindow->Viewport == NULL. Release build, IM_ASSERT disabled.Config:
DockingEnable | ViewportsEnable | NavEnableKeyboard | NavEnableGamepad,ConfigDpiScaleFonts = ConfigDpiScaleViewports = true.Callstack (4 crash dumps, all identical):
Repro steps
HostWindowpointing to it. Two frames later the host viewport is destroyed, soHostWindow->Viewport == NULL.If A's rect is not contained in the main viewport, the merge returns early and a new viewport is created: no crash.
What happens in WindowSelectViewport() for A
ViewportOwned = false,Viewport == NULL,ViewportIdstill refers to the destroyed viewport, so the restore block callsAddUpdateViewport(), which setsViewportOwned = true.ImGuiWindowFlags_ChildWindow):window->Viewport = window->ParentWindow->Viewport-> NULL,ViewportOwnedstays true.UpdateTryMergeWindowIntoHostViewport(window, main_viewport): withViewportOwnedandold_viewport == NULL, the loop callsSetWindowViewport()on every window with a NULL viewport, A included ->window->Viewport->Window.Local workaround
We are not sure this is the right place to fix it. The stale
HostWindowof the empty node may be the actual root cause.Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code: