Fix leak when calling remove_control_from_menu_panel

This commit is contained in:
Haoyu Qiu 2023-09-23 14:01:52 +08:00
parent c12d63556b
commit 2d67ce4e60
2 changed files with 6 additions and 2 deletions

View file

@ -4979,9 +4979,11 @@ void CanvasItemEditor::remove_control_from_menu_panel(Control *p_control) {
p_control->disconnect("visibility_changed", callable_mp(this, &CanvasItemEditor::_update_context_toolbar)); p_control->disconnect("visibility_changed", callable_mp(this, &CanvasItemEditor::_update_context_toolbar));
context_toolbar_hbox->remove_child(context_toolbar_separators[p_control]); VSeparator *sep = context_toolbar_separators[p_control];
context_toolbar_hbox->remove_child(sep);
context_toolbar_hbox->remove_child(p_control); context_toolbar_hbox->remove_child(p_control);
context_toolbar_separators.erase(p_control); context_toolbar_separators.erase(p_control);
memdelete(sep);
_update_context_toolbar(); _update_context_toolbar();
} }

View file

@ -7695,9 +7695,11 @@ void Node3DEditor::remove_control_from_menu_panel(Control *p_control) {
p_control->disconnect("visibility_changed", callable_mp(this, &Node3DEditor::_update_context_toolbar)); p_control->disconnect("visibility_changed", callable_mp(this, &Node3DEditor::_update_context_toolbar));
context_toolbar_hbox->remove_child(context_toolbar_separators[p_control]); VSeparator *sep = context_toolbar_separators[p_control];
context_toolbar_hbox->remove_child(sep);
context_toolbar_hbox->remove_child(p_control); context_toolbar_hbox->remove_child(p_control);
context_toolbar_separators.erase(p_control); context_toolbar_separators.erase(p_control);
memdelete(sep);
_update_context_toolbar(); _update_context_toolbar();
} }