diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index f62eaee96ed2..1396f16dd265 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -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)); - 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_separators.erase(p_control); + memdelete(sep); _update_context_toolbar(); } diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 2215c371d042..98ffcd11f6d5 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -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)); - 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_separators.erase(p_control); + memdelete(sep); _update_context_toolbar(); }