Skip to content

Commit

Permalink
Fix division by zero in aspect ratio calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
patwork committed Jun 30, 2024
1 parent 4ab8fb8 commit 3162974
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion editor/plugins/canvas_item_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,7 @@ bool CanvasItemEditor::_gui_input_resize(const Ref<InputEvent> &p_event) {
bool symmetric = m->is_alt_pressed();

Rect2 local_rect = ci->_edit_get_rect();
real_t aspect = local_rect.get_size().y / local_rect.get_size().x;
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);
Point2 current_begin = local_rect.get_position();
Point2 current_end = local_rect.get_position() + local_rect.get_size();
Point2 max_begin = (symmetric) ? (current_begin + current_end - ci->_edit_get_minimum_size()) / 2.0 : current_end - ci->_edit_get_minimum_size();
Expand Down

0 comments on commit 3162974

Please sign in to comment.