From c0f0f26615990ae90112b94313869f06124f2c13 Mon Sep 17 00:00:00 2001 From: Markus Sauermann <6299227+Sauermann@users.noreply.github.com> Date: Wed, 5 Oct 2022 23:26:41 +0200 Subject: [PATCH] Fix Control not disconnecting signal If a Control has not parent CanvasItem and is set as top_level, then it does not disconnect from the "size_changed" signal when it leaves the Canvas. This patch corrects this. --- scene/gui/control.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index dc9294df6d0..290ac39c781 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -2885,8 +2885,8 @@ void Control::_notification(int p_notification) { if (data.parent_canvas_item) { data.parent_canvas_item->disconnect("item_rect_changed", callable_mp(this, &Control::_size_changed)); data.parent_canvas_item = nullptr; - } else if (!is_set_as_top_level()) { - //disconnect viewport + } else { + // Disconnect viewport. Viewport *viewport = get_viewport(); ERR_FAIL_COND(!viewport); viewport->disconnect("size_changed", callable_mp(this, &Control::_size_changed));