[nautilus] search-engine-tracker: complete search in idle if we got no connection
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] search-engine-tracker: complete search in idle if we got no connection
- Date: Fri, 28 Sep 2012 15:30:22 +0000 (UTC)
commit 892ed29cedb248db6611a4b919a0f325532810fa
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Fri Sep 28 11:25:36 2012 -0400
search-engine-tracker: complete search in idle if we got no connection
Instead of returning a NULL engine, which will cause criticals later,
since NautilusSearchEngine will still try to call start() on it.
https://bugzilla.gnome.org/show_bug.cgi?id=685014
.../nautilus-search-engine-tracker.c | 35 ++++++++++++--------
1 files changed, 21 insertions(+), 14 deletions(-)
---
diff --git a/libnautilus-private/nautilus-search-engine-tracker.c b/libnautilus-private/nautilus-search-engine-tracker.c
index 1f7d60d..1d002fb 100644
--- a/libnautilus-private/nautilus-search-engine-tracker.c
+++ b/libnautilus-private/nautilus-search-engine-tracker.c
@@ -212,6 +212,15 @@ query_callback (GObject *object,
cursor_next (tracker, cursor);
}
+static gboolean
+search_finished_idle (gpointer user_data)
+{
+ NautilusSearchProvider *provider = user_data;
+ nautilus_search_provider_finished (provider);
+
+ return FALSE;
+}
+
static void
nautilus_search_engine_tracker_start (NautilusSearchProvider *provider)
{
@@ -227,6 +236,10 @@ nautilus_search_engine_tracker_start (NautilusSearchProvider *provider)
return;
}
+ if (tracker->details->connection == NULL) {
+ g_idle_add (search_finished_idle, provider);
+ return;
+ }
query_text = nautilus_query_get_text (tracker->details->query);
downcase = g_utf8_strdown (query_text, -1);
@@ -338,29 +351,23 @@ nautilus_search_engine_tracker_class_init (NautilusSearchEngineTrackerClass *cla
static void
nautilus_search_engine_tracker_init (NautilusSearchEngineTracker *engine)
{
+ GError *error = NULL;
+
engine->details = G_TYPE_INSTANCE_GET_PRIVATE (engine, NAUTILUS_TYPE_SEARCH_ENGINE_TRACKER,
NautilusSearchEngineTrackerDetails);
engine->details->hits_pending = g_queue_new ();
-}
-
-NautilusSearchEngineTracker *
-nautilus_search_engine_tracker_new (void)
-{
- NautilusSearchEngineTracker *engine;
- TrackerSparqlConnection *connection;
- GError *error = NULL;
-
- connection = tracker_sparql_connection_get (NULL, &error);
+ engine->details->connection = tracker_sparql_connection_get (NULL, &error);
if (error) {
g_warning ("Could not establish a connection to Tracker: %s", error->message);
g_error_free (error);
- return NULL;
}
+}
- engine = g_object_new (NAUTILUS_TYPE_SEARCH_ENGINE_TRACKER, NULL);
- engine->details->connection = connection;
- return engine;
+NautilusSearchEngineTracker *
+nautilus_search_engine_tracker_new (void)
+{
+ return g_object_new (NAUTILUS_TYPE_SEARCH_ENGINE_TRACKER, NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]