diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-01-11 20:06:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-11 20:06:38 +0100 |
commit | b563de702c7a0dbb5bbf9507c684e3deadc95134 (patch) | |
tree | 698fb8ad6546787f5526a605c74ae7d0c28a38b8 | |
parent | f118bd6861b3a05cae3994d7cf4f5f07b0ffb006 (diff) | |
parent | 22c15083afdf29e741d7b5fed966d2f09ca994aa (diff) |
Merge pull request #35019 from Paulb23/issue_35016_line_edit_backspace_crash
Fix empty LineEdit crash on ctrl+backspace
-rw-r--r-- | scene/gui/line_edit.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 5351b6cadc..a6cd9a0665 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1193,7 +1193,7 @@ void LineEdit::delete_char() { set_cursor_position(get_cursor_position() - 1); if (align == ALIGN_CENTER || align == ALIGN_RIGHT) { - window_pos = CLAMP(window_pos - 1, 0, text.length() - 1); + window_pos = CLAMP(window_pos - 1, 0, MAX(text.length() - 1, 0)); } _text_changed(); @@ -1224,7 +1224,7 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) { } if (align == ALIGN_CENTER || align == ALIGN_RIGHT) { - window_pos = CLAMP(window_pos - (p_to_column - p_from_column), 0, text.length() - 1); + window_pos = CLAMP(window_pos - (p_to_column - p_from_column), 0, MAX(text.length() - 1, 0)); } if (!text_changed_dirty) { |