[gnome-builder/wip/chergert/deploy] pipeline: be more careful about pipeline initialization



commit d361823f6743f86c9ba45bf9676ed53ee2dde163
Author: Christian Hergert <chergert redhat com>
Date:   Wed Mar 7 13:40:50 2018 -0800

    pipeline: be more careful about pipeline initialization
    
    If we're accessing the pipeline directly, we might need to check that it is
    ready before completing operations. This helps ensure we don't access the
    build directory before it is ready.

 src/libide/buildsystem/ide-build-manager.c  |  4 ++-
 src/libide/buildsystem/ide-build-pipeline.c |  2 ++
 src/plugins/meson/gbp-meson-build-system.c  | 44 ++++++++++++++++++-----------
 3 files changed, 32 insertions(+), 18 deletions(-)
---
diff --git a/src/libide/buildsystem/ide-build-manager.c b/src/libide/buildsystem/ide-build-manager.c
index 1298f329e..aeb16f8f6 100644
--- a/src/libide/buildsystem/ide-build-manager.c
+++ b/src/libide/buildsystem/ide-build-manager.c
@@ -1292,7 +1292,9 @@ ide_build_manager_execute_async (IdeBuildManager     *self,
   g_task_set_priority (task, G_PRIORITY_LOW);
   g_task_set_return_on_cancel (task, TRUE);
 
-  if (self->pipeline == NULL || self->can_build == FALSE)
+  if (self->pipeline == NULL ||
+      self->can_build == FALSE ||
+      !ide_build_pipeline_is_ready (self->pipeline))
     {
       g_task_return_new_error (task,
                                G_IO_ERROR,
diff --git a/src/libide/buildsystem/ide-build-pipeline.c b/src/libide/buildsystem/ide-build-pipeline.c
index 33e84d4a7..7b5d390e2 100644
--- a/src/libide/buildsystem/ide-build-pipeline.c
+++ b/src/libide/buildsystem/ide-build-pipeline.c
@@ -2466,6 +2466,7 @@ ide_build_pipeline_build_srcdir_path (IdeBuildPipeline *self,
   va_list args;
 
   g_return_val_if_fail (IDE_IS_BUILD_PIPELINE (self), NULL);
+  g_return_val_if_fail (self->srcdir != NULL, NULL);
   g_return_val_if_fail (first_part != NULL, NULL);
 
   va_start (args, first_part);
@@ -2495,6 +2496,7 @@ ide_build_pipeline_build_builddir_path (IdeBuildPipeline *self,
   va_list args;
 
   g_return_val_if_fail (IDE_IS_BUILD_PIPELINE (self), NULL);
+  g_return_val_if_fail (self->builddir != NULL, NULL);
   g_return_val_if_fail (first_part != NULL, NULL);
 
   va_start (args, first_part);
diff --git a/src/plugins/meson/gbp-meson-build-system.c b/src/plugins/meson/gbp-meson-build-system.c
index cf71d5a02..1b2529e83 100644
--- a/src/plugins/meson/gbp-meson-build-system.c
+++ b/src/plugins/meson/gbp-meson-build-system.c
@@ -248,6 +248,7 @@ gbp_meson_build_system_load_commands_async (GbpMesonBuildSystem *self,
                                             gpointer             user_data)
 {
   g_autoptr(GTask) task = NULL;
+  g_autofree gchar *path = NULL;
   IdeBuildManager *build_manager;
   IdeBuildPipeline *pipeline;
   IdeContext *context;
@@ -283,30 +284,39 @@ gbp_meson_build_system_load_commands_async (GbpMesonBuildSystem *self,
   build_manager = ide_context_get_build_manager (context);
   pipeline = ide_build_manager_get_pipeline (build_manager);
 
-  if (pipeline != NULL)
+  /*
+   * Because we're accessing the pipeline directly, we need to be careful
+   * here about whether or not it is setup fully. It may be delayed due
+   * to device initialization.
+   */
+  if (pipeline == NULL || !ide_build_pipeline_is_ready (pipeline))
     {
-      g_autofree gchar *path = NULL;
+      g_task_return_new_error (task,
+                               G_IO_ERROR,
+                               G_IO_ERROR_NOT_INITIALIZED,
+                               "The pipeline is not yet ready to handle requests");
+      return;
+    }
 
-      path = ide_build_pipeline_build_builddir_path (pipeline, "compile_commands.json", NULL);
+  path = ide_build_pipeline_build_builddir_path (pipeline, "compile_commands.json", NULL);
 
-      if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
-        {
-          g_autoptr(IdeCompileCommands) compile_commands = NULL;
-          g_autoptr(GFile) file = NULL;
+  if (g_file_test (path, G_FILE_TEST_IS_REGULAR))
+    {
+      g_autoptr(IdeCompileCommands) compile_commands = NULL;
+      g_autoptr(GFile) file = NULL;
 
-          compile_commands = ide_compile_commands_new ();
-          file = g_file_new_for_path (path);
+      compile_commands = ide_compile_commands_new ();
+      file = g_file_new_for_path (path);
 
-          ide_compile_commands_load_async (compile_commands,
-                                           file,
-                                           cancellable,
-                                           gbp_meson_build_system_load_commands_load_cb,
-                                           g_steal_pointer (&task));
+      ide_compile_commands_load_async (compile_commands,
+                                       file,
+                                       cancellable,
+                                       gbp_meson_build_system_load_commands_load_cb,
+                                       g_steal_pointer (&task));
 
-          gbp_meson_build_system_monitor (self, file);
+      gbp_meson_build_system_monitor (self, file);
 
-          return;
-        }
+      return;
     }
 
   /*


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