Fix EditorPlugin::remove_control_from_docks freeing passed control

This commit is contained in:
kleonc
2026-03-11 21:22:34 +01:00
parent dff2b9bb66
commit cdc278dfa6
+4
View File
@@ -93,6 +93,7 @@ Button *EditorPlugin::add_control_to_bottom_panel(Control *p_control, const Stri
void EditorPlugin::add_control_to_dock(DockSlot p_slot, Control *p_control, const Ref<Shortcut> &p_shortcut) {
ERR_FAIL_NULL(p_control);
ERR_FAIL_COND(legacy_docks.has(p_control));
ERR_FAIL_COND(p_control->get_parent() != nullptr);
EditorDock *dock = memnew(EditorDock);
dock->set_title(p_control->get_name());
@@ -108,6 +109,9 @@ void EditorPlugin::remove_control_from_docks(Control *p_control) {
ERR_FAIL_NULL(p_control);
ERR_FAIL_COND(!legacy_docks.has(p_control));
// Ensure freeing the legacy dock won't free `p_control` (freeing it is up to the user).
legacy_docks[p_control]->remove_child(p_control);
EditorDockManager::get_singleton()->remove_dock(legacy_docks[p_control]);
legacy_docks[p_control]->queue_free();
legacy_docks.erase(p_control);