From 8d44d5b8fae0d145e9698edcd2c752ff8755a307 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Mon, 23 Sep 2002 11:50:12 +0000 Subject: move success notification code to its own code block, since it was being 2002-09-23 Rodrigo Moya * pcs/query.c (start_cached_query_cb): move success notification code to its own code block, since it was being run for parse errors also. Also, remove all traces of the query from the cache if there is an error. Also, use GINT_TO_POINTER instead of GPOINTER_TO_INT. svn path=/trunk/; revision=18165 --- calendar/pcs/query.c | 61 +++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 27 deletions(-) (limited to 'calendar/pcs/query.c') diff --git a/calendar/pcs/query.c b/calendar/pcs/query.c index 15b5c41ec2..19686e2d4d 100644 --- a/calendar/pcs/query.c +++ b/calendar/pcs/query.c @@ -1458,15 +1458,18 @@ start_cached_query_cb (gpointer data) GTK_SIGNAL_FUNC (listener_died_cb), info->query); priv->cached_timeouts = g_list_remove (priv->cached_timeouts, - GPOINTER_TO_INT (info->tid)); + GINT_TO_POINTER (info->tid)); - g_free (info); - - return FALSE; } else if (priv->state == QUERY_IN_PROGRESS) { /* if it's in progress, we just wait */ return TRUE; } else if (priv->state == QUERY_PARSE_ERROR) { + /* remove all traces of this query */ + g_source_remove (info->tid); + priv->cached_timeouts = g_list_remove (priv->cached_timeouts, + GINT_TO_POINTER (info->tid)); + + /* notify listener of error */ CORBA_exception_init (&ev); GNOME_Evolution_Calendar_QueryListener_notifyQueryDone ( info->ql, @@ -1479,33 +1482,37 @@ start_cached_query_cb (gpointer data) "a parse error"); CORBA_exception_free (&ev); - } - /* if the query is done, then we just notify the listener */ - g_source_remove (info->tid); - priv->cached_timeouts = g_list_remove (priv->cached_timeouts, - GPOINTER_TO_INT (info->tid)); - - g_hash_table_foreach (priv->uids, (GHFunc) notify_uid_cb, info); + cached_queries = g_list_remove (cached_queries, info->query); + bonobo_object_unref (BONOBO_OBJECT (info->query)); + } else if (priv->state == QUERY_DONE) { + g_source_remove (info->tid); + priv->cached_timeouts = g_list_remove (priv->cached_timeouts, + GINT_TO_POINTER (info->tid)); - priv->listeners = g_list_append (priv->listeners, info->ql); + /* if the query is done, then we just notify the listener */ + g_hash_table_foreach (priv->uids, (GHFunc) notify_uid_cb, info); - cl = e_component_listener_new (info->ql, 0); - priv->component_listeners = g_list_append (priv->component_listeners, cl); - gtk_signal_connect (GTK_OBJECT (cl), "component_died", - GTK_SIGNAL_FUNC (listener_died_cb), info->query); + priv->listeners = g_list_append (priv->listeners, info->ql); - CORBA_exception_init (&ev); - GNOME_Evolution_Calendar_QueryListener_notifyQueryDone ( - info->ql, - GNOME_Evolution_Calendar_QueryListener_SUCCESS, - "", - &ev); - if (BONOBO_EX (&ev)) - g_message ("start_cached_query_cb(): Could not notify the listener of " - "a finished query"); + cl = e_component_listener_new (info->ql, 0); + priv->component_listeners = g_list_append (priv->component_listeners, cl); + gtk_signal_connect (GTK_OBJECT (cl), "component_died", + GTK_SIGNAL_FUNC (listener_died_cb), info->query); - CORBA_exception_free (&ev); + CORBA_exception_init (&ev); + GNOME_Evolution_Calendar_QueryListener_notifyQueryDone ( + info->ql, + GNOME_Evolution_Calendar_QueryListener_SUCCESS, + "", + &ev); + if (BONOBO_EX (&ev)) + g_message ("start_cached_query_cb(): Could not notify the listener of " + "a finished query"); + + CORBA_exception_free (&ev); + } + g_free (info); return FALSE; @@ -1544,7 +1551,7 @@ backend_destroyed_cb (GtkObject *object, gpointer data) query = QUERY (data); cached_queries = g_list_remove (cached_queries, query); - bonobo_object_unref (query); + bonobo_object_unref (BONOBO_OBJECT (query)); } /** -- cgit v1.2.3