[gnome-builder] code-index: handle not-yet-loaded service



commit 5e3f45256da4248c599dc64340da3131df296826
Author: Christian Hergert <chergert redhat com>
Date:   Mon Apr 16 02:45:40 2018 -0700

    code-index: handle not-yet-loaded service
    
    Be more defensive here. The real issue is that we're not loading
    services immediately before this added even got to load. But
    this helps mitigate it until we get that fixed.

 .../code-index/ide-code-index-search-provider.c       | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)
---
diff --git a/src/plugins/code-index/ide-code-index-search-provider.c 
b/src/plugins/code-index/ide-code-index-search-provider.c
index 9fe3dc969..702bd98a5 100644
--- a/src/plugins/code-index/ide-code-index-search-provider.c
+++ b/src/plugins/code-index/ide-code-index-search-provider.c
@@ -74,18 +74,23 @@ ide_code_index_search_provider_search_async (IdeSearchProvider   *provider,
   g_assert (IDE_IS_CODE_INDEX_SERVICE (service));
 
   index = ide_code_index_service_get_index (service);
-  g_assert (IDE_IS_CODE_INDEX_INDEX (index));
 
   task = ide_task_new (self, cancellable, callback, user_data);
   ide_task_set_source_tag (task, ide_code_index_search_provider_search_async);
   ide_task_set_priority (task, G_PRIORITY_LOW);
 
-  ide_code_index_index_populate_async (index,
-                                       search_terms,
-                                       max_results,
-                                       cancellable,
-                                       populate_cb,
-                                       g_steal_pointer (&task));
+  if (index == NULL)
+    ide_task_return_new_error (task,
+                               G_IO_ERROR,
+                               G_IO_ERROR_NOT_SUPPORTED,
+                               "Code index is not currently available");
+  else
+    ide_code_index_index_populate_async (index,
+                                         search_terms,
+                                         max_results,
+                                         cancellable,
+                                         populate_cb,
+                                         g_steal_pointer (&task));
 
   IDE_EXIT;
 }


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