diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2011-09-08 15:00:21 -0400 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2011-09-08 15:22:26 -0400 |
commit | 920aa3d94be890f241d3be415540dbde6a81df0a (patch) | |
tree | e0111adc789bebfad2cf0e76924206a45b37ad8e /libnautilus-private/nautilus-search-engine-tracker.c | |
parent | ee73c255d75165607c7f04defd5e8edfa3524914 (diff) | |
download | nautilus-920aa3d94be890f241d3be415540dbde6a81df0a.tar.gz |
tracker: always reset the cancellable when starting a query
Otherwise we can start a query with a cancelled object already, making
it fail immediately.
Diffstat (limited to 'libnautilus-private/nautilus-search-engine-tracker.c')
-rw-r--r-- | libnautilus-private/nautilus-search-engine-tracker.c | 40 |
1 files changed, 13 insertions, 27 deletions
diff --git a/libnautilus-private/nautilus-search-engine-tracker.c b/libnautilus-private/nautilus-search-engine-tracker.c index a94159390..15f85c188 100644 --- a/libnautilus-private/nautilus-search-engine-tracker.c +++ b/libnautilus-private/nautilus-search-engine-tracker.c @@ -38,13 +38,12 @@ struct NautilusSearchEngineTrackerDetails { TrackerSparqlConnection *connection; - GCancellable *cancellable; + NautilusQuery *query; - NautilusQuery *query; - gboolean query_pending; + gboolean query_pending; + GCancellable *cancellable; }; - G_DEFINE_TYPE (NautilusSearchEngineTracker, nautilus_search_engine_tracker, NAUTILUS_TYPE_SEARCH_ENGINE); @@ -111,22 +110,18 @@ cursor_callback (GObject *object, success = tracker_sparql_cursor_next_finish (cursor, result, &error); if (error) { + tracker->details->query_pending = FALSE; nautilus_search_engine_error (NAUTILUS_SEARCH_ENGINE (tracker), error->message); g_error_free (error); - - if (cursor) { - g_object_unref (cursor); - } + g_object_unref (cursor); return; } if (!success) { + tracker->details->query_pending = FALSE; nautilus_search_engine_finished (NAUTILUS_SEARCH_ENGINE (tracker)); - - if (cursor) { - g_object_unref (cursor); - } + g_object_unref (cursor); return; } @@ -152,20 +147,20 @@ query_callback (GObject *object, tracker = NAUTILUS_SEARCH_ENGINE_TRACKER (user_data); - tracker->details->query_pending = FALSE; - connection = TRACKER_SPARQL_CONNECTION (object); cursor = tracker_sparql_connection_query_finish (connection, result, &error); if (error) { + tracker->details->query_pending = FALSE; nautilus_search_engine_error (NAUTILUS_SEARCH_ENGINE (tracker), error->message); g_error_free (error); return; } if (!cursor) { + tracker->details->query_pending = FALSE; nautilus_search_engine_finished (NAUTILUS_SEARCH_ENGINE (tracker)); return; } @@ -192,6 +187,8 @@ nautilus_search_engine_tracker_start (NautilusSearchEngine *engine) return; } + g_cancellable_reset (tracker->details->cancellable); + search_text = nautilus_query_get_text (tracker->details->query); location_uri = nautilus_query_get_location (tracker->details->query); mimetypes = nautilus_query_get_mime_types (tracker->details->query); @@ -363,31 +360,20 @@ NautilusSearchEngine * nautilus_search_engine_tracker_new (void) { NautilusSearchEngineTracker *engine; - GCancellable *cancellable; TrackerSparqlConnection *connection; GError *error = NULL; - cancellable = g_cancellable_new (); - connection = tracker_sparql_connection_get (cancellable, &error); + 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); - g_object_unref (cancellable); - - return NULL; - } else if (!connection) { - g_warning ("Could not establish a connection to Tracker, no TrackerSparqlConnection was returned"); - g_object_unref (cancellable); - return NULL; } engine = g_object_new (NAUTILUS_TYPE_SEARCH_ENGINE_TRACKER, NULL); - engine->details->connection = connection; - engine->details->cancellable = cancellable; - engine->details->query_pending = FALSE; + engine->details->cancellable = g_cancellable_new (); return NAUTILUS_SEARCH_ENGINE (engine); } |