From 3f2c88fd0f1c284881b5d63655850619017185d9 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Wed, 31 Oct 2001 12:49:54 +0000 Subject: If a query is not in progress, just retag the whole thing. An event may 2001-10-31 Federico Mena Quintero * gui/gnome-cal.c (dn_query_obj_updated_cb): If a query is not in progress, just retag the whole thing. An event may change dates and tag_calendar_by_comp() would not know how to untag the old dates. Fixes bug #10220. * pcs/query.c (start_query_cb): Connect to the backend's "obj_updated" and "obj_removed" signals here instead of in query_construct(). If a query is started while another one is notifying of an update, these signal connections would get appened to the running signal (the one that triggered the notification about an update) and the new signal handlers would also get called. We are really not interested in updates before we populate the query, because we'll catch the changes anyways. svn path=/trunk/; revision=14533 --- calendar/pcs/query.c | 82 ++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) (limited to 'calendar/pcs/query.c') diff --git a/calendar/pcs/query.c b/calendar/pcs/query.c index 28513d3822..33289ed107 100644 --- a/calendar/pcs/query.c +++ b/calendar/pcs/query.c @@ -1265,6 +1265,40 @@ populate_query (Query *query) priv->state = QUERY_IN_PROGRESS; } +/* Callback used when a component changes in the backend */ +static void +backend_obj_updated_cb (CalBackend *backend, const char *uid, gpointer data) +{ + Query *query; + + query = QUERY (data); + + bonobo_object_ref (BONOBO_OBJECT (query)); + + match_component (query, uid, FALSE, 0, 0); + remove_from_pending (query, uid); + + bonobo_object_unref (BONOBO_OBJECT (query)); +} + +/* Callback used when a component is removed from the backend */ +static void +backend_obj_removed_cb (CalBackend *backend, const char *uid, gpointer data) +{ + Query *query; + QueryPrivate *priv; + + query = QUERY (data); + priv = query->priv; + + bonobo_object_ref (BONOBO_OBJECT (query)); + + remove_component (query, uid); + remove_from_pending (query, uid); + + bonobo_object_unref (BONOBO_OBJECT (query)); +} + /* Idle handler for starting a query */ static gboolean start_query_cb (gpointer data) @@ -1284,6 +1318,13 @@ start_query_cb (gpointer data) populate_query (query); + gtk_signal_connect (GTK_OBJECT (priv->backend), "obj_updated", + GTK_SIGNAL_FUNC (backend_obj_updated_cb), + query); + gtk_signal_connect (GTK_OBJECT (priv->backend), "obj_removed", + GTK_SIGNAL_FUNC (backend_obj_removed_cb), + query); + return FALSE; } @@ -1307,40 +1348,6 @@ backend_opened_cb (CalBackend *backend, CalBackendOpenStatus status, gpointer da } } -/* Callback used when a component changes in the backend */ -static void -backend_obj_updated_cb (CalBackend *backend, const char *uid, gpointer data) -{ - Query *query; - - query = QUERY (data); - - bonobo_object_ref (BONOBO_OBJECT (query)); - - match_component (query, uid, FALSE, 0, 0); - remove_from_pending (query, uid); - - bonobo_object_unref (BONOBO_OBJECT (query)); -} - -/* Callback used when a component is removed from the backend */ -static void -backend_obj_removed_cb (CalBackend *backend, const char *uid, gpointer data) -{ - Query *query; - QueryPrivate *priv; - - query = QUERY (data); - priv = query->priv; - - bonobo_object_ref (BONOBO_OBJECT (query)); - - remove_component (query, uid); - remove_from_pending (query, uid); - - bonobo_object_unref (BONOBO_OBJECT (query)); -} - /** * query_construct: * @query: A live search query. @@ -1388,13 +1395,6 @@ query_construct (Query *query, priv->default_zone = cal_backend_get_default_timezone (backend); - gtk_signal_connect (GTK_OBJECT (priv->backend), "obj_updated", - GTK_SIGNAL_FUNC (backend_obj_updated_cb), - query); - gtk_signal_connect (GTK_OBJECT (priv->backend), "obj_removed", - GTK_SIGNAL_FUNC (backend_obj_removed_cb), - query); - priv->sexp = g_strdup (sexp); /* Queue the query to be started asynchronously */ -- cgit v1.2.3