Fixed crashes when renaming a state in AnimationNodeStateMachineEditor

Recursive calls to Control::_modal_stack_remove could cause a crash because of the list element not being invalidated while being erased from the list.

It happens in the state machine case by hiding a line edit control when it loses focus.

Fixes #23808
This commit is contained in:
PouleyKetchoupp 2019-10-22 16:28:11 +02:00
parent 1be39232b4
commit e3d4b96ba7
2 changed files with 4 additions and 3 deletions

View File

@ -2221,9 +2221,11 @@ void Control::_modal_stack_remove() {
if (!data.MI) if (!data.MI)
return; return;
get_viewport()->_gui_remove_from_modal_stack(data.MI, data.modal_prev_focus_owner); List<Control *>::Element *element = data.MI;
data.MI = NULL; data.MI = NULL;
get_viewport()->_gui_remove_from_modal_stack(element, data.modal_prev_focus_owner);
data.modal_prev_focus_owner = 0; data.modal_prev_focus_owner = 0;
} }

View File

@ -2374,7 +2374,6 @@ void Viewport::_gui_remove_from_modal_stack(List<Control *>::Element *MI, Object
List<Control *>::Element *next = MI->next(); List<Control *>::Element *next = MI->next();
gui.modal_stack.erase(MI); gui.modal_stack.erase(MI);
MI = NULL;
if (p_prev_focus_owner) { if (p_prev_focus_owner) {