From cdc278dfa6cce19f9a638050035bb1e9dda57998 Mon Sep 17 00:00:00 2001 From: kleonc <9283098+kleonc@users.noreply.github.com> Date: Wed, 11 Mar 2026 21:22:34 +0100 Subject: [PATCH] Fix `EditorPlugin::remove_control_from_docks` freeing passed control --- editor/plugins/editor_plugin.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/editor/plugins/editor_plugin.cpp b/editor/plugins/editor_plugin.cpp index be0bb7e8b1..95fba96b03 100644 --- a/editor/plugins/editor_plugin.cpp +++ b/editor/plugins/editor_plugin.cpp @@ -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 &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);