From 1c47fd7089a5d77632e64add0beefecffb688217 Mon Sep 17 00:00:00 2001 From: Hendrik Brucker Date: Fri, 5 Jul 2024 01:41:21 +0200 Subject: [PATCH] Fix Control nodes emitting unnecessary resized signals --- scene/gui/control.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 0682c11a9b2..1d53edbfa66 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1732,11 +1732,15 @@ void Control::_size_changed() { new_size_cache.height = minimum_size.height; } - bool pos_changed = new_pos_cache != data.pos_cache; - bool size_changed = new_size_cache != data.size_cache; + bool pos_changed = !new_pos_cache.is_equal_approx(data.pos_cache); + bool size_changed = !new_size_cache.is_equal_approx(data.size_cache); - data.pos_cache = new_pos_cache; - data.size_cache = new_size_cache; + if (pos_changed) { + data.pos_cache = new_pos_cache; + } + if (size_changed) { + data.size_cache = new_size_cache; + } if (is_inside_tree()) { if (pos_changed || size_changed) { @@ -1751,12 +1755,10 @@ void Control::_size_changed() { } if (pos_changed && !size_changed) { - _update_canvas_item_transform(); //move because it won't be updated - } - } else { - if (pos_changed) { - _notify_transform(); + _update_canvas_item_transform(); } + } else if (pos_changed) { + _notify_transform(); } }