[nautilus] tracker: always reset the cancellable when starting a query
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] tracker: always reset the cancellable when starting a query
- Date: Thu, 8 Sep 2011 19:22:54 +0000 (UTC)
commit 920aa3d94be890f241d3be415540dbde6a81df0a
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu Sep 8 15:00:21 2011 -0400
tracker: always reset the cancellable when starting a query
Otherwise we can start a query with a cancelled object already, making
it fail immediately.
.../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 a941593..15f85c1 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]