Bugfix: Godot engine crashes due to _clear function

This commit is contained in:
Xavier Sellier 2018-02-15 13:38:01 -05:00
parent 8befa3dd2f
commit d7c349fea4

View file

@ -3204,9 +3204,11 @@ String TextEdit::get_line(int line) const {
void TextEdit::_clear() { void TextEdit::_clear() {
if (undo_enabled) { if (undo_enabled) {
_clear_redo();
String undo_text = get_text(); String undo_text = get_text();
if (undo_text.length() > 0) {
_clear_redo();
/* UNDO!! */ /* UNDO!! */
TextOperation op; TextOperation op;
op.type = TextOperation::TYPE_CLEAR; op.type = TextOperation::TYPE_CLEAR;
@ -3222,6 +3224,7 @@ void TextEdit::_clear() {
op.prev_version = get_version(); op.prev_version = get_version();
_push_current_op(); _push_current_op();
current_op = op; current_op = op;
}
} else { } else {
clear_undo_history(); clear_undo_history();
} }