[gnome-builder] libide/code: be more resilient with buffer signals
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/code: be more resilient with buffer signals
- Date: Wed, 21 Sep 2022 00:25:37 +0000 (UTC)
commit 11859447c4deef6a93fc85892e751d188783df27
Author: Christian Hergert <chergert redhat com>
Date: Tue Sep 20 17:18:49 2022 -0700
libide/code: be more resilient with buffer signals
src/libide/code/ide-text-edit.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/src/libide/code/ide-text-edit.c b/src/libide/code/ide-text-edit.c
index 89203ae70..f25f96dd9 100644
--- a/src/libide/code/ide-text-edit.c
+++ b/src/libide/code/ide-text-edit.c
@@ -188,6 +188,8 @@ _ide_text_edit_apply (IdeTextEdit *self,
gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer), &begin, priv->begin_mark);
gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer), &end, priv->end_mark);
gtk_text_buffer_delete (GTK_TEXT_BUFFER (buffer), &begin, &end);
+ /* Refetch insert mark incase signal handlers modified things */
+ gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (buffer), &begin, priv->begin_mark);
gtk_text_buffer_insert (GTK_TEXT_BUFFER (buffer), &begin, priv->text, -1);
gtk_text_buffer_delete_mark (GTK_TEXT_BUFFER (buffer), priv->begin_mark);
gtk_text_buffer_delete_mark (GTK_TEXT_BUFFER (buffer), priv->end_mark);
@@ -210,13 +212,12 @@ _ide_text_edit_prepare (IdeTextEdit *self,
end = ide_range_get_end (priv->range);
ide_buffer_get_iter_at_location (buffer, &begin_iter, begin);
- ide_buffer_get_iter_at_location (buffer, &end_iter, end);
-
priv->begin_mark = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (buffer),
NULL,
&begin_iter,
TRUE);
+ ide_buffer_get_iter_at_location (buffer, &end_iter, end);
priv->end_mark = gtk_text_buffer_create_mark (GTK_TEXT_BUFFER (buffer),
NULL,
&end_iter,
@@ -318,12 +319,8 @@ ide_text_edit_set_text (IdeTextEdit *self,
g_return_if_fail (IDE_IS_TEXT_EDIT (self));
- if (!ide_str_equal0 (priv->text, text))
- {
- g_free (priv->text);
- priv->text = g_strdup (text);
- g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TEXT]);
- }
+ if (ide_set_string (&priv->text, text))
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_TEXT]);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]