aboutsummaryrefslogtreecommitdiff
path: root/libindicator
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-11-03 22:23:16 -0600
committerTed Gould <ted@canonical.com>2009-11-03 22:23:16 -0600
commite354bc4560602a9dbcf73ed8ca3b4ace7297c58a (patch)
tree7eb59fbbde06806ea47372825f050c701eb43363 /libindicator
parent03e89036c7db8eb1afcdc39b4de81863b4ee41f4 (diff)
downloadlibayatana-indicator-e354bc4560602a9dbcf73ed8ca3b4ace7297c58a.tar.gz
libayatana-indicator-e354bc4560602a9dbcf73ed8ca3b4ace7297c58a.tar.bz2
libayatana-indicator-e354bc4560602a9dbcf73ed8ca3b4ace7297c58a.zip
Changing the way the module is free'd
Diffstat (limited to 'libindicator')
-rw-r--r--libindicator/indicator-object.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c
index db4b819..442ba78 100644
--- a/libindicator/indicator-object.c
+++ b/libindicator/indicator-object.c
@@ -100,21 +100,37 @@ indicator_object_init (IndicatorObject *self)
static void
indicator_object_dispose (GObject *object)
{
- IndicatorObjectPrivate * priv = INDICATOR_OBJECT_GET_PRIVATE(object);
-
- if (priv->module != NULL) {
- g_object_unref(priv->module);
- priv->module = NULL;
- }
G_OBJECT_CLASS (indicator_object_parent_class)->dispose (object);
return;
}
+/* A small helper function that unreferences an object but
+ in the function prototype of a GSourceFunc. */
+static gboolean
+module_unref (gpointer data)
+{
+ g_object_unref(G_OBJECT(data));
+ return FALSE;
+}
+
/* Free memory */
static void
indicator_object_finalize (GObject *object)
{
+ IndicatorObjectPrivate * priv = INDICATOR_OBJECT_GET_PRIVATE(object);
+
+ if (priv->module != NULL) {
+ /* Wow, this is convoluted. So basically we want to unref
+ the module which will cause the code it included to be
+ removed. But, since it's finalize function is the function
+ that called this one, we can't really remove it before
+ it finishes being executed. So we're putting the job into
+ the main loop to remove it the next time it gets a chance.
+ Slightly non-deterministic, but should work. */
+ g_idle_add(module_unref, priv->module);
+ priv->module = NULL;
+ }
G_OBJECT_CLASS (indicator_object_parent_class)->finalize (object);
return;