Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when hiding subwindow during popup of new subwindow #80780

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions scene/main/viewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ void Viewport::_sub_window_grab_focus(Window *p_window) {
return;
}

// The index needs to be update before every usage in case an event callback changed the window list.
int index = _sub_window_find(p_window);
ERR_FAIL_COND(index == -1);

Expand All @@ -374,6 +375,8 @@ void Viewport::_sub_window_grab_focus(Window *p_window) {
gui.subwindow_drag = SUB_WINDOW_DRAG_DISABLED;
}
// Can only move to foreground, but no focus granted.
index = _sub_window_find(p_window);
ERR_FAIL_COND(index == -1);
SubWindow sw = gui.sub_windows[index];
gui.sub_windows.remove_at(index);
gui.sub_windows.push_back(sw);
Expand Down Expand Up @@ -401,6 +404,8 @@ void Viewport::_sub_window_grab_focus(Window *p_window) {
gui.subwindow_focused->_event_callback(DisplayServer::WINDOW_EVENT_FOCUS_IN);

{ // Move to foreground.
index = _sub_window_find(p_window);
ERR_FAIL_COND(index == -1);
SubWindow sw = gui.sub_windows[index];
gui.sub_windows.remove_at(index);
gui.sub_windows.push_back(sw);
Expand Down