Skip to content

Commit f9474f0

Browse files
committed
Merge pull request #93764 from patwork/fix-aspect-div-by-zero
Fix division by zero in aspect ratio calculation
2 parents 107fed8 + 3162974 commit f9474f0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

editor/plugins/canvas_item_editor_plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1796,7 +1796,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
17961796
bool symmetric = m->is_alt_pressed();
17971797

17981798
Rect2 local_rect = ci->_edit_get_rect();
1799-
real_t aspect = local_rect.get_size().y / local_rect.get_size().x;
1799+
real_t aspect = local_rect.has_area() ? (local_rect.get_size().y / local_rect.get_size().x) : (local_rect.get_size().y + 1.0) / (local_rect.get_size().x + 1.0);
18001800
Point2 current_begin = local_rect.get_position();
18011801
Point2 current_end = local_rect.get_position() + local_rect.get_size();
18021802
Point2 max_begin = (symmetric) ? (current_begin + current_end - ci->_edit_get_minimum_size()) / 2.0 : current_end - ci->_edit_get_minimum_size();

0 commit comments

Comments
 (0)