[gnome-builder] foundry: delay build-manager startup



commit b54584921086cb3294ff85703472da3e935400eb
Author: Christian Hergert <chergert redhat com>
Date:   Fri Mar 22 16:53:43 2019 -0700

    foundry: delay build-manager startup
    
    We don't want to initialize build pipelines until the workspace
    window has been displayed to the user. That ensures that systems
    like the runtime-manager have a toplevel to attach any dialogs
    to (such as might be necessary for user interaction).

 src/libide/foundry/ide-build-manager.c | 18 ++++++++++++++++--
 src/libide/foundry/ide-build-private.h |  1 +
 src/libide/gui/ide-workbench.c         |  8 ++++++++
 3 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/libide/foundry/ide-build-manager.c b/src/libide/foundry/ide-build-manager.c
index 74096307e..6a8d3082b 100644
--- a/src/libide/foundry/ide-build-manager.c
+++ b/src/libide/foundry/ide-build-manager.c
@@ -84,6 +84,7 @@ struct _IdeBuildManager
 
   guint             timer_source;
 
+  guint             started : 1;
   guint             can_build : 1;
   guint             can_export : 1;
   guint             building : 1;
@@ -595,8 +596,10 @@ ide_build_manager_invalidate_pipeline (IdeBuildManager *self)
   self->error_count = 0;
   self->warning_count = 0;
 
-  /* Don't setup anything new if we're in shutdown */
-  if (ide_object_in_destruction (IDE_OBJECT (context)))
+  /* Don't setup anything new if we're in shutdown or we haven't
+   * been told we are allowed to start.
+   */
+  if (ide_object_in_destruction (IDE_OBJECT (context)) || !self->started)
     IDE_EXIT;
 
   config_manager = ide_config_manager_from_context (context);
@@ -1876,3 +1879,14 @@ ide_build_manager_get_warning_count (IdeBuildManager *self)
 
   return self->warning_count;
 }
+
+void
+_ide_build_manager_start (IdeBuildManager *self)
+{
+  g_return_if_fail (IDE_IS_BUILD_MANAGER (self));
+  g_return_if_fail (self->started == FALSE);
+
+  self->started = TRUE;
+
+  ide_build_manager_invalidate (self);
+}
diff --git a/src/libide/foundry/ide-build-private.h b/src/libide/foundry/ide-build-private.h
index 7abd11716..1304225c1 100644
--- a/src/libide/foundry/ide-build-private.h
+++ b/src/libide/foundry/ide-build-private.h
@@ -42,5 +42,6 @@ void    _ide_pipeline_check_toolchain       (IdePipeline *self,
 void    _ide_pipeline_set_pty_size          (IdePipeline *self,
                                              guint             rows,
                                              guint             columns);
+void    _ide_build_manager_start            (IdeBuildManager *self);
 
 G_END_DECLS
diff --git a/src/libide/gui/ide-workbench.c b/src/libide/gui/ide-workbench.c
index 321b73154..2a30bf361 100644
--- a/src/libide/gui/ide-workbench.c
+++ b/src/libide/gui/ide-workbench.c
@@ -27,6 +27,7 @@
 #include <libide-threading.h>
 #include <libpeas/peas.h>
 
+#include "ide-build-private.h"
 #include "ide-context-private.h"
 #include "ide-foundry-init.h"
 #include "ide-thread-private.h"
@@ -968,6 +969,7 @@ static void
 ide_workbench_load_project_completed (IdeWorkbench *self,
                                       IdeTask      *task)
 {
+  IdeBuildManager *build_manager;
   LoadProject *lp;
 
   g_assert (IDE_IS_WORKBENCH (self));
@@ -1009,6 +1011,12 @@ ide_workbench_load_project_completed (IdeWorkbench *self,
                              ide_workbench_session_restore_cb,
                              NULL);
 
+  /* Now that we have a workspace window for the project, we can allow
+   * the build manager to start.
+   */
+  build_manager = ide_build_manager_from_context (self->context);
+  _ide_build_manager_start (build_manager);
+
   ide_task_return_boolean (task, TRUE);
 }
 


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