[gnome-builder/wip/gtk4-port] plugins/clang: be a bit more resilient



commit 2ec72e40bae34c41f1fb380fc8a798db6e2f07ab
Author: Christian Hergert <chergert redhat com>
Date:   Tue Apr 26 12:57:46 2022 -0700

    plugins/clang: be a bit more resilient

 src/plugins/clang/ide-clang-symbol-resolver.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
---
diff --git a/src/plugins/clang/ide-clang-symbol-resolver.c b/src/plugins/clang/ide-clang-symbol-resolver.c
index 90406c636..a1fb6a808 100644
--- a/src/plugins/clang/ide-clang-symbol-resolver.c
+++ b/src/plugins/clang/ide-clang-symbol-resolver.c
@@ -300,6 +300,7 @@ find_nearest_scope_flags_cb (GObject      *object,
   IdeBuildSystem *build_system = (IdeBuildSystem *)object;
   g_autoptr(IdeTask) task = user_data;
   g_autoptr(IdeClangClient) client = NULL;
+  g_autoptr(GError) error = NULL;
   g_auto(GStrv) flags = NULL;
   IdeLocation *location;
   GCancellable *cancellable;
@@ -312,8 +313,24 @@ find_nearest_scope_flags_cb (GObject      *object,
   g_assert (G_IS_ASYNC_RESULT (result));
   g_assert (IDE_IS_TASK (task));
 
-  flags = ide_build_system_get_build_flags_finish (build_system, result, NULL);
-  context = ide_object_get_context (IDE_OBJECT (build_system));
+  if (!(flags = ide_build_system_get_build_flags_finish (build_system, result, &error)))
+    {
+      if (!ide_error_ignore (error))
+        {
+          ide_task_return_error (task, g_steal_pointer (&error));
+          return;
+        }
+    }
+
+  if (!(context = ide_object_get_context (IDE_OBJECT (build_system))))
+    {
+      ide_task_return_new_error (task,
+                                 G_IO_ERROR,
+                                 G_IO_ERROR_CANCELLED,
+                                 "Operation cancelled");
+      return;
+    }
+
   client = ide_object_ensure_child_typed (IDE_OBJECT (context), IDE_TYPE_CLANG_CLIENT);
   cancellable = ide_task_get_cancellable (task);
   location = ide_task_get_task_data (task);
@@ -333,7 +350,7 @@ find_nearest_scope_flags_cb (GObject      *object,
 
 static void
 ide_clang_symbol_resolver_find_nearest_scope_async (IdeSymbolResolver   *symbol_resolver,
-                                                    IdeLocation   *location,
+                                                    IdeLocation         *location,
                                                     GCancellable        *cancellable,
                                                     GAsyncReadyCallback  callback,
                                                     gpointer             user_data)


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