[gnome-builder/gnome-builder-3-24] sourceview: ensure we have valid textmarks for animations



commit e15852ac6a015a9f1198523e6e76d19f91331277
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 b9828b4..b9cc43e 100644
--- a/libide/sourceview/ide-source-view.c
+++ b/libide/sourceview/ide-source-view.c
@@ -7829,30 +7829,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]