[gnome-builder] buffer: set the initial state to loading



commit 61b047026c811c22ece34a85945aeafdf2962971
Author: Christian Hergert <chergert redhat com>
Date:   Sun Jun 18 01:02:36 2017 -0700

    buffer: set the initial state to loading
    
    This allows us to set the buffer state to loading and then ack that state
    once the BUFFER_LOADED signal is emitted in the buffer manager. This helps
    ensure that we have a consistent flow for this. And doing that makes it
    easier to disable various features while loading the buffer.

 libide/buffers/ide-buffer-manager.c |    6 ++----
 libide/buffers/ide-buffer.c         |   10 ++++++++--
 2 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/libide/buffers/ide-buffer-manager.c b/libide/buffers/ide-buffer-manager.c
index a2ce8ef..b085aab 100644
--- a/libide/buffers/ide-buffer-manager.c
+++ b/libide/buffers/ide-buffer-manager.c
@@ -542,7 +542,6 @@ ide_buffer_manager_load_file__load_cb (GObject      *object,
        */
       if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
         {
-          _ide_buffer_set_loading (state->buffer, FALSE);
           g_task_return_error (task, error);
           return;
         }
@@ -618,7 +617,6 @@ ide_buffer_manager_load_file__load_cb (GObject      *object,
     _ide_file_set_content_type (state->file, content_type);
 
 emit_signal:
-  _ide_buffer_set_loading (state->buffer, FALSE);
 
   if (!_ide_context_is_restoring (context))
     ide_buffer_manager_set_focus_buffer (self, state->buffer);
@@ -660,7 +658,6 @@ ide_buffer_manager__load_file_query_info_cb (GObject      *object,
     {
       if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
         {
-          _ide_buffer_set_loading (state->buffer, FALSE);
           g_task_return_error (task, error);
           IDE_EXIT;
         }
@@ -849,7 +846,6 @@ ide_buffer_manager_load_file_async (IdeBufferManager       *self,
 
   _ide_buffer_set_mtime (state->buffer, NULL);
   _ide_buffer_set_changed_on_volume (state->buffer, FALSE);
-  _ide_buffer_set_loading (state->buffer, TRUE);
 
   g_task_set_task_data (task, state, load_state_free);
 
@@ -1213,6 +1209,8 @@ ide_buffer_manager_real_buffer_loaded (IdeBufferManager *self,
   recent_data.is_private = FALSE;
 
   gtk_recent_manager_add_full (recent_manager, uri, &recent_data);
+
+  _ide_buffer_set_loading (buffer, FALSE);
 }
 
 static IdeBuffer *
diff --git a/libide/buffers/ide-buffer.c b/libide/buffers/ide-buffer.c
index 2e78305..221ad7b 100644
--- a/libide/buffers/ide-buffer.c
+++ b/libide/buffers/ide-buffer.c
@@ -617,7 +617,7 @@ ide_buffer_reload_change_monitor (IdeBuffer *self)
       g_clear_object (&priv->change_monitor);
     }
 
-  if (priv->context && priv->file)
+  if (!priv->loading && priv->context && priv->file)
     {
       IdeVcs *vcs;
 
@@ -1073,6 +1073,9 @@ ide_buffer_loaded (IdeBuffer *self)
   if (priv->change_monitor != NULL)
     ide_buffer_change_monitor_reload (priv->change_monitor);
 
+  /* This is suspended until we've loaded */
+  ide_highlight_engine_unpause (priv->highlight_engine);
+
   IDE_EXIT;
 }
 
@@ -1225,6 +1228,7 @@ ide_buffer_constructed (GObject *object)
                            G_CONNECT_SWAPPED);
 
   priv->highlight_engine = ide_highlight_engine_new (self);
+  ide_highlight_engine_pause (priv->highlight_engine);
 
   priv->formatter_adapter = ide_extension_adapter_new (priv->context,
                                                        NULL,
@@ -1616,6 +1620,8 @@ ide_buffer_init (IdeBuffer *self)
 
   IDE_ENTRY;
 
+  priv->loading = TRUE;
+
   priv->highlight_diagnostics = TRUE;
 
   priv->file_signals = dzl_signal_group_new (IDE_TYPE_FILE);
@@ -2438,7 +2444,7 @@ ide_buffer_rehighlight (IdeBuffer *self)
   g_return_if_fail (IDE_IS_BUFFER (self));
 
   /* In case we are disposing */
-  if (priv->highlight_engine == NULL)
+  if (priv->highlight_engine == NULL || priv->loading)
     IDE_EXIT;
 
   if (gtk_source_buffer_get_highlight_syntax (GTK_SOURCE_BUFFER (self)))


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