Commit 02efd83b authored by Christian Hergert's avatar Christian Hergert
Browse files

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.
parent 79a16224
......@@ -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,
......
......@@ -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);
......
......@@ -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;
}
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment