[evolution-data-server/gnome-2-30] Don't leave dangling stale pointers to ECal's in the backend
- From: Michael Meeks <michael src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-2-30] Don't leave dangling stale pointers to ECal's in the backend
- Date: Thu, 8 Apr 2010 12:57:16 +0000 (UTC)
commit d4e3edf2a8974c8d5b5667162a041314fafa6663
Author: Michael Meeks <michael meeks novell com>
Date: Thu Apr 8 13:57:35 2010 +0100
Don't leave dangling stale pointers to ECal's in the backend
calendar/libedata-cal/e-cal-backend.c | 42 ++++++++++++++++++---------------
1 files changed, 23 insertions(+), 19 deletions(-)
---
diff --git a/calendar/libedata-cal/e-cal-backend.c b/calendar/libedata-cal/e-cal-backend.c
index f5fb71b..a45ccaf 100644
--- a/calendar/libedata-cal/e-cal-backend.c
+++ b/calendar/libedata-cal/e-cal-backend.c
@@ -85,6 +85,7 @@ enum {
static guint e_cal_backend_signals[LAST_SIGNAL];
static void e_cal_backend_finalize (GObject *object);
+static void e_cal_backend_remove_client_private (ECalBackend *backend, EDataCal *cal, gboolean weak_unref);
@@ -383,9 +384,10 @@ e_cal_backend_get_kind (ECalBackend *backend)
}
static void
-last_client_gone (ECalBackend *backend)
+cal_destroy_cb (gpointer data, GObject *where_cal_was)
{
- g_signal_emit (backend, e_cal_backend_signals[LAST_CLIENT_GONE], 0);
+ e_cal_backend_remove_client_private (E_CAL_BACKEND (data),
+ (EDataCal *) where_cal_was, FALSE);
}
/**
@@ -408,29 +410,15 @@ e_cal_backend_add_client (ECalBackend *backend, EDataCal *cal)
priv = backend->priv;
- /* TODO: Implement this? */
-#if 0
- bonobo_object_set_immortal (BONOBO_OBJECT (cal), TRUE);
-
g_object_weak_ref (G_OBJECT (cal), cal_destroy_cb, backend);
- ORBit_small_listen_for_broken (e_data_cal_get_listener (cal), G_CALLBACK (listener_died_cb), cal);
-#endif
-
g_mutex_lock (priv->clients_mutex);
priv->clients = g_list_append (priv->clients, cal);
g_mutex_unlock (priv->clients_mutex);
}
-/**
- * e_cal_backend_remove_client:
- * @backend: An #ECalBackend object.
- * @cal: An #EDataCal object.
- *
- * Removes a client from the list of connected clients to the given backend.
- */
-void
-e_cal_backend_remove_client (ECalBackend *backend, EDataCal *cal)
+static void
+e_cal_backend_remove_client_private (ECalBackend *backend, EDataCal *cal, gboolean weak_unref)
{
ECalBackendPrivate *priv;
@@ -444,6 +432,9 @@ e_cal_backend_remove_client (ECalBackend *backend, EDataCal *cal)
priv = backend->priv;
+ if (weak_unref)
+ g_object_weak_unref (G_OBJECT (cal), cal_destroy_cb, backend);
+
/* Disconnect */
g_mutex_lock (priv->clients_mutex);
priv->clients = g_list_remove (priv->clients, cal);
@@ -453,7 +444,20 @@ e_cal_backend_remove_client (ECalBackend *backend, EDataCal *cal)
* it may decide whether to kill the backend or not.
*/
if (!priv->clients)
- last_client_gone (backend);
+ g_signal_emit (backend, e_cal_backend_signals[LAST_CLIENT_GONE], 0);
+}
+
+/**
+ * e_cal_backend_remove_client:
+ * @backend: An #ECalBackend object.
+ * @cal: An #EDataCal object.
+ *
+ * Removes a client from the list of connected clients to the given backend.
+ */
+void
+e_cal_backend_remove_client (ECalBackend *backend, EDataCal *cal)
+{
+ e_cal_backend_remove_client_private (backend, cal, TRUE);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]