[PATCH 03/14] tracker: rewrite error handling in search method



From: Lionel Landwerlin <lionel g landwerlin linux intel com>

Signed-off-by: Lionel Landwerlin <lionel g landwerlin linux intel com>
---
 src/tracker/grl-tracker.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/tracker/grl-tracker.c b/src/tracker/grl-tracker.c
index 50ea307..2a45382 100644
--- a/src/tracker/grl-tracker.c
+++ b/src/tracker/grl-tracker.c
@@ -684,13 +684,18 @@ grl_tracker_source_search (GrlMediaSource *source, GrlMediaSourceSearchSpec *ss)
 
   GRL_DEBUG ("grl_tracker_source_search");
 
+  if (!ss->text || ss->text[0] == '\0') {
+    error = g_error_new_literal (GRL_CORE_ERROR,
+                                 GRL_CORE_ERROR_QUERY_FAILED,
+                                 "Empty search");
+    goto send_error;
+  }
+
   if (priv->tracker_connection == NULL) {
     error = g_error_new (GRL_CORE_ERROR,
                          GRL_CORE_ERROR_SEARCH_FAILED,
                          "Failed to start search action");
-    ss->callback (ss->source, ss->search_id, NULL, 0, ss->user_data, error);
-    g_error_free (error);
-          return;
+    goto send_error;
   }
 
   sparql_select = get_select_string (source, ss->keys);
@@ -719,4 +724,10 @@ grl_tracker_source_search (GrlMediaSource *source, GrlMediaSourceSearchSpec *ss)
     g_free (sparql_select);
   if (sparql_final != NULL)
     g_free (sparql_final);
+
+  return;
+
+ send_error:
+  ss->callback (ss->source, ss->search_id, NULL, 0, ss->user_data, error);
+  g_error_free (error);
 }
-- 
1.7.2.3



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