[gnome-builder] editor: avoid async spinloop



commit f9b48d73e50906fab4ee0a0df7dc9a37c53c7daf
Author: Christian Hergert <chergert redhat com>
Date:   Tue May 10 17:50:24 2016 +0300

    editor: avoid async spinloop
    
    We could get in a state if the view was closed while we were loading it
    that we would try again but fail. And then continue to do that since the
    buffer was already open (but no longer necessary to attach a view to it).
    
    This just prevents us from trying a third time in the retry case.

 libide/editor/ide-editor-perspective.c |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)
---
diff --git a/libide/editor/ide-editor-perspective.c b/libide/editor/ide-editor-perspective.c
index 71ee5f6..4ba06ec 100644
--- a/libide/editor/ide-editor-perspective.c
+++ b/libide/editor/ide-editor-perspective.c
@@ -49,9 +49,12 @@ typedef struct
   IdeSourceLocation    *location;
 } FocusLocation;
 
-static void ide_perspective_iface_init (IdePerspectiveInterface *iface);
-
-static void ide_editor_perspective_add (GtkContainer *container, GtkWidget *widget);
+static void ide_perspective_iface_init                 (IdePerspectiveInterface *iface);
+static void ide_editor_perspective_add                 (GtkContainer            *container,
+                                                        GtkWidget               *widget);
+static void ide_editor_perspective_focus_location_full (IdeEditorPerspective    *self,
+                                                        IdeSourceLocation       *location,
+                                                        gboolean                 open_if_not_found);
 
 G_DEFINE_TYPE_EXTENDED (IdeEditorPerspective, ide_editor_perspective, IDE_TYPE_LAYOUT, 0,
                         G_IMPLEMENT_INTERFACE (IDE_TYPE_PERSPECTIVE, ide_perspective_iface_init))
@@ -557,7 +560,7 @@ ide_editor_perspective_focus_location_cb (GObject      *object,
     }
 
   /* try again now that we have loaded */
-  ide_editor_perspective_focus_location (state->self, state->location);
+  ide_editor_perspective_focus_location_full (state->self, state->location, FALSE);
 
 cleanup:
   g_object_unref (state->self);
@@ -565,9 +568,10 @@ cleanup:
   g_slice_free (FocusLocation, state);
 }
 
-void
-ide_editor_perspective_focus_location (IdeEditorPerspective *self,
-                                       IdeSourceLocation    *location)
+static void
+ide_editor_perspective_focus_location_full (IdeEditorPerspective *self,
+                                            IdeSourceLocation    *location,
+                                            gboolean              open_if_not_found)
 {
   struct {
     IdeFile *file;
@@ -585,6 +589,9 @@ ide_editor_perspective_focus_location (IdeEditorPerspective *self,
                                  ide_editor_perspective_find_source_location,
                                  &lookup);
 
+  if (!open_if_not_found && lookup.view == NULL)
+    return;
+
   if (lookup.view == NULL)
     {
       FocusLocation *state;
@@ -615,3 +622,10 @@ ide_editor_perspective_focus_location (IdeEditorPerspective *self,
   ide_layout_view_navigate_to (IDE_LAYOUT_VIEW (lookup.view), location);
   gtk_widget_grab_focus (GTK_WIDGET (lookup.view));
 }
+
+void
+ide_editor_perspective_focus_location (IdeEditorPerspective *self,
+                                       IdeSourceLocation    *location)
+{
+  ide_editor_perspective_focus_location_full (self, location, TRUE);
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]