Repository navigation
Keep a closed panel's callbacks alive until its frame is drawn - #333
Merged
Merged
Conversation
Ctrl+W, Ctrl+F4 and a tab menu's Close close a docked panel while input is handled, after the frame is built and before it's drawn. ClosePanel destroyed the panel there, and with it what its callbacks held. A viewport built that frame had already queued its scene with a pointer into that state, and the scene read freed memory when it was drawn. - ClosePanel and closing a layout's panels take them out of the layout at once and give their IDs back, but keep the Panel objects until the next frame starts (BeginDockingFrame), or until Cleanup. - Docs: closing a panel from an input handler. - Tests: a panel closed by a click on a button in it is out of the layout and its ID is back at once, while what its callback holds lives until the next frame starts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closing a docked panel with Ctrl+W, Ctrl+F4 or its tab menu's Close could make the frame read freed memory.
Cause
ClosePaneldestroyed thePanelthere, and with it what its callbacks held. In the showcase, that's the panel's own state.controls_viewport.cpp,RenderScene). When the frame was drawn, the scene callback read freed memory.What changes
ClosePanelwaits to destroy:ClosePanel, and closing all of a layout's panels, still take the panels out of the layout at once and give their IDs back. ThePanelobjects are now kept until the next frame starts (BeginDockingFrame), or untilCleanup.Tests
Validation
gui_core_tests,gui_vulkan_tests,gui_gpu_tests,gui_d3d12_testsandgui_sdlgpu_testsall pass on Windows.--benchrun reports no errors.