Skip to content

Commit 3162974

Browse files
committed
Fix division by zero in aspect ratio calculation
1 parent 4ab8fb8 commit 3162974

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
@@ -1786,7 +1786,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
17861786
bool symmetric = m->is_alt_pressed();
17871787

17881788
Rect2 local_rect = ci->_edit_get_rect();
1789-
real_t aspect = local_rect.get_size().y / local_rect.get_size().x;
1789+
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);
17901790
Point2 current_begin = local_rect.get_position();
17911791
Point2 current_end = local_rect.get_position() + local_rect.get_size();
17921792
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)