Linux deltas double free and newline fix (flutter/engine#32168)

* Fix double free

* Fix entering a newline

* Formatting

Co-authored-by: Renzo Olivares <roliv@google.com>
This commit is contained in:
Renzo Olivares
2022-03-22 12:13:13 -07:00
committed by GitHub
parent 09f006dff3
commit 0d9b02f227

View File

@@ -216,7 +216,7 @@ static void update_editing_state_with_delta(FlTextInputPlugin* self,
g_autoptr(FlValue) deltas = fl_value_new_list();
fl_value_append(deltas, deltaValue);
g_autoptr(FlValue) value = fl_value_new_map();
FlValue* value = fl_value_new_map();
fl_value_set_string_take(value, "deltas", deltas);
fl_value_append(args, value);
@@ -629,6 +629,7 @@ static gboolean fl_text_input_plugin_filter_keypress_default(
std::string text_before_change = priv->text_model->GetText();
flutter::TextRange selection_before_change = priv->text_model->selection();
std::string text = priv->text_model->GetText();
// Handle the enter/return key.
gboolean do_action = FALSE;
@@ -649,6 +650,7 @@ static gboolean fl_text_input_plugin_filter_keypress_default(
case GDK_KEY_ISO_Enter:
if (priv->input_type == FL_TEXT_INPUT_TYPE_MULTILINE) {
priv->text_model->AddCodePoint('\n');
text = "\n";
changed = TRUE;
}
do_action = TRUE;
@@ -676,8 +678,7 @@ static gboolean fl_text_input_plugin_filter_keypress_default(
if (changed) {
if (priv->enable_delta_model) {
flutter::TextEditingDelta delta = flutter::TextEditingDelta(
text_before_change, priv->text_model->selection(),
priv->text_model->GetText());
text_before_change, selection_before_change, text);
update_editing_state_with_delta(self, &delta);
} else {
update_editing_state(self);