From b278cc483730a8dfda15b187ea75837eeb351826 Mon Sep 17 00:00:00 2001 From: square <74556856+r3square@users.noreply.github.com> Date: Wed, 16 Apr 2025 02:30:25 +0200 Subject: [PATCH] Fix division by zero when scaling --- editor/plugins/canvas_item_editor_plugin.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index f4685cb4e8..28749170e2 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -2035,7 +2035,14 @@ bool CanvasItemEditor::_gui_input_scale(const Ref &p_event) { Size2 scale_max; if (drag_type != DRAG_SCALE_BOTH) { for (CanvasItem *ci : drag_selection) { - scale_max = scale_max.max(ci->_edit_get_scale()); + Size2 scale = ci->_edit_get_scale(); + + if (Math::abs(scale.x) > Math::abs(scale_max.x)) { + scale_max.x = scale.x; + } + if (Math::abs(scale.y) > Math::abs(scale_max.y)) { + scale_max.y = scale.y; + } } }