Skip to content

Commit

Permalink
Docking: Fix appending to windows causing a child window to be insert…
Browse files Browse the repository at this point in the history
…ed to g.WindowsFocusOrder which eventually causes a crash. (ocornut#5515)
  • Loading branch information
rokups committed Aug 2, 2022
1 parent 7ff00cc commit 35c4944
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Other Changes:
- Backends: Metal: Add dispatch synchronization. (#5447) [@luigifcruz]
- Backends: OSX: Fixes to support full app creation in C++. (#5403) [@stack]
- TabBar: Fixed a crash when closing multiple docked windows with appended tab button. [@rokups]
- Window: Fixed a potential crash when appending to a child window. [@rokups] (#5515)


-----------------------------------------------------------------------
Expand Down
7 changes: 4 additions & 3 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6087,7 +6087,10 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
const bool window_just_created = (window == NULL);
if (window_just_created)
window = CreateNewWindow(name, flags);
else

const int current_frame = g.FrameCount;
const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame);
if (first_begin_of_the_frame)
UpdateWindowInFocusOrderList(window, window_just_created, flags);

// Automatically disable manual moving/resizing when NoInputs is set
Expand All @@ -6097,8 +6100,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
if (flags & ImGuiWindowFlags_NavFlattened)
IM_ASSERT(flags & ImGuiWindowFlags_ChildWindow);

const int current_frame = g.FrameCount;
const bool first_begin_of_the_frame = (window->LastFrameActive != current_frame);
window->IsFallbackWindow = (g.CurrentWindowStack.Size == 0 && g.WithinFrameScopeWithImplicitWindow);

// Update the Appearing flag
Expand Down

0 comments on commit 35c4944

Please sign in to comment.