From 2bd5999a46871c499f7e162692dc26efdb791129 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Thu, 19 Sep 2002 18:39:46 +0000 Subject: added a list of EComponentListener's to control the lifetime of the 2002-09-19 Rodrigo Moya * pcs/query.c: added a list of EComponentListener's to control the lifetime of the listeners. (query_init): initialize new member. (query_destroy): free new member. (start_cached_query_cb): create a EComponentListener for the new listener being added. svn path=/trunk/; revision=18122 --- calendar/pcs/query.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'calendar/pcs') diff --git a/calendar/pcs/query.c b/calendar/pcs/query.c index 686620c686..73d40324b2 100644 --- a/calendar/pcs/query.c +++ b/calendar/pcs/query.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -67,6 +68,7 @@ struct _QueryPrivate { /* Listeners to which we report changes in the live query */ GList *listeners; + GList *component_listeners; /* Sexp that defines the query */ char *sexp; @@ -138,6 +140,7 @@ query_init (Query *query) priv->qb = NULL; priv->default_zone = NULL; priv->listeners = NULL; + priv->component_listeners = NULL; priv->sexp = NULL; priv->timeout_id = 0; @@ -211,6 +214,12 @@ query_destroy (GtkObject *object) priv->listeners = NULL; } + if (priv->component_listeners != NULL) { + g_list_foreach (priv->component_listeners, (GFunc) gtk_object_unref, NULL); + g_list_free (priv->component_listeners); + priv->component_listeners = NULL; + } + if (priv->sexp) { g_free (priv->sexp); priv->sexp = NULL; @@ -1386,6 +1395,20 @@ start_query_cb (gpointer data) return FALSE; } +static void +listener_died_cb (EComponentListener *cl, gpointer data) +{ + QueryPrivate *priv; + Query *query = QUERY (data); + + priv = query->priv; + + priv->listeners = g_list_remove (priv->listeners, e_component_listener_get_component (cl)); + + priv->component_listeners = g_list_remove (priv->component_listeners, cl); + gtk_object_unref (GTK_OBJECT (cl)); +} + static void notify_uid_cb (gpointer key, gpointer value, gpointer data) { @@ -1415,6 +1438,7 @@ start_cached_query_cb (gpointer data) { CORBA_Environment ev; QueryPrivate *priv; + EComponentListener *cl; StartCachedQueryInfo *info = (StartCachedQueryInfo *) data; priv = info->query->priv; @@ -1424,10 +1448,16 @@ start_cached_query_cb (gpointer data) priv->state == QUERY_WAIT_FOR_BACKEND) { priv->listeners = g_list_append (priv->listeners, info->ql); - g_free (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->cached_timeouts = g_list_remove (priv->cached_timeouts, GPOINTER_TO_INT (info->tid)); + g_free (info); + return FALSE; } else if (priv->state == QUERY_IN_PROGRESS) { /* if it's in progress, we just wait */ @@ -1443,6 +1473,11 @@ start_cached_query_cb (gpointer data) priv->listeners = g_list_append (priv->listeners, info->ql); + 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_init (&ev); GNOME_Evolution_Calendar_QueryListener_notifyQueryDone ( info->ql, -- cgit