[gnome-builder/wip/libide] libide: try to be clever about returning errors.



commit 7bfeabbacefb331cd68163570eea5ffe05528091
Author: Christian Hergert <christian hergert me>
Date:   Wed Feb 11 22:00:05 2015 -0800

    libide: try to be clever about returning errors.

 libide/ide-diagnostician.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/libide/ide-diagnostician.c b/libide/ide-diagnostician.c
index b72ee81..6db3bf7 100644
--- a/libide/ide-diagnostician.c
+++ b/libide/ide-diagnostician.c
@@ -32,6 +32,7 @@ typedef struct
 typedef struct
 {
   IdeDiagnostics *diagnostics;
+  guint           total;
   guint           active;
 } DiagnoseState;
 
@@ -111,12 +112,12 @@ diagnose_cb (GObject      *object,
   ide_diagnostics_unref (ret);
 
 maybe_complete:
-  if (!state->active)
-    {
-      g_task_return_pointer (task,
-                             ide_diagnostics_ref (state->diagnostics),
-                             (GDestroyNotify)ide_diagnostics_unref);
-    }
+  if (state->total == 1 && error)
+    g_task_return_error (task, error);
+  else if (!state->active)
+    g_task_return_pointer (task,
+                           ide_diagnostics_ref (state->diagnostics),
+                           (GDestroyNotify)ide_diagnostics_unref);
 }
 
 void
@@ -147,6 +148,7 @@ ide_diagnostician_diagnose_async (IdeDiagnostician    *self,
 
   state = g_slice_new0 (DiagnoseState);
   state->active = priv->providers->len;
+  state->total = priv->providers->len;
   state->diagnostics = _ide_diagnostics_new (NULL);
 
   g_task_set_task_data (task, state, diagnose_state_free);


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