[gnome-builder] sourceview: ensure we have valid textmarks for animations
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] sourceview: ensure we have valid textmarks for animations
- Date: Wed, 17 May 2017 00:45:48 +0000 (UTC)
commit 854174dd6f9905efce9842ee93e42fb945a4e0ba
Author: Christian Hergert <chergert redhat com>
Date: Tue May 16 17:44:22 2017 -0700
sourceview: ensure we have valid textmarks for animations
This checks that the marks we got from the source snippet are valid.
Otherwise the textiters could be left in an invalid state.
This also checks to ensure that animations are enabled before calling the
animation helper.
https://bugzilla.gnome.org/show_bug.cgi?id=782701
libide/sourceview/ide-source-view.c | 49 +++++++++++++++++++---------------
1 files changed, 27 insertions(+), 22 deletions(-)
---
diff --git a/libide/sourceview/ide-source-view.c b/libide/sourceview/ide-source-view.c
index 2a92296..3507d9b 100644
--- a/libide/sourceview/ide-source-view.c
+++ b/libide/sourceview/ide-source-view.c
@@ -7987,30 +7987,35 @@ ide_source_view_push_snippet (IdeSourceView *self,
ide_source_view_unblock_handlers (self);
gtk_text_buffer_end_user_action (buffer);
- {
- GtkTextMark *mark_begin;
- GtkTextMark *mark_end;
- GtkTextIter begin;
- GtkTextIter end;
+ if (!ide_source_view_can_animate (self))
+ {
+ GtkTextMark *mark_begin;
+ GtkTextMark *mark_end;
- mark_begin = ide_source_snippet_get_mark_begin (snippet);
- mark_end = ide_source_snippet_get_mark_end (snippet);
+ mark_begin = ide_source_snippet_get_mark_begin (snippet);
+ mark_end = ide_source_snippet_get_mark_end (snippet);
- gtk_text_buffer_get_iter_at_mark (buffer, &begin, mark_begin);
- gtk_text_buffer_get_iter_at_mark (buffer, &end, mark_end);
+ if (mark_begin != NULL && mark_end != NULL)
+ {
+ GtkTextIter begin;
+ GtkTextIter end;
- /*
- * HACK:
- *
- * We need to let the GtkTextView catch up with us so that we can get a realistic area back for
- * the location of the end iter. Without pumping the main loop, GtkTextView will clamp the
- * result to the height of the insert line.
- */
- while (gtk_events_pending ())
- gtk_main_iteration ();
+ gtk_text_buffer_get_iter_at_mark (buffer, &begin, mark_begin);
+ gtk_text_buffer_get_iter_at_mark (buffer, &end, mark_end);
- animate_expand (self, &begin, &end);
- }
+ /*
+ * HACK:
+ *
+ * We need to let the GtkTextView catch up with us so that we can get a realistic area back for
+ * the location of the end iter. Without pumping the main loop, GtkTextView will clamp the
+ * result to the height of the insert line.
+ */
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
+
+ animate_expand (self, &begin, &end);
+ }
+ }
if (!has_more_tab_stops)
ide_source_view_pop_snippet (self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]