summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Taylor <rob.taylor@codethink.co.uk>2007-08-04 12:06:11 +0100
committerRob Taylor <rob.taylor@codethink.co.uk>2007-08-04 12:06:11 +0100
commit52fd5092e577d917540321321c8140569614eb3d (patch)
tree6fae7ec725819bd41ff59a5c6b1b687667c968d7
parent836b28b43070e1e4600245f8e95fe315ab27bd15 (diff)
unref owned objects in dispose, not finalize
Modified ohm-keystore and ohm-manager to unref owned objects in dispose, not finalize.
-rw-r--r--ohmd/ohm-keystore.c24
-rw-r--r--ohmd/ohm-manager.c31
2 files changed, 46 insertions, 9 deletions
diff --git a/ohmd/ohm-keystore.c b/ohmd/ohm-keystore.c
index 0e5421e..f680a83 100644
--- a/ohmd/ohm-keystore.c
+++ b/ohmd/ohm-keystore.c
@@ -137,10 +137,10 @@ ohm_keystore_get_keys (OhmKeystore *keystore,
}
/**
- * ohm_keystore_finalize:
+ * ohm_keystore_dispose:
**/
static void
-ohm_keystore_finalize (GObject *object)
+ohm_keystore_dispose (GObject *object)
{
OhmKeystore *keystore;
g_return_if_fail (object != NULL);
@@ -149,10 +149,25 @@ ohm_keystore_finalize (GObject *object)
g_object_unref (keystore->priv->conf);
- g_return_if_fail (keystore->priv != NULL);
+ G_OBJECT_CLASS (ohm_keystore_parent_class)->dispose (object);
+}
+
+/**
+ * ohm_keystore_finalize:
+ **/
+static void
+ohm_keystore_finalize (GObject *object)
+{
+ OhmKeystore *keystore;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (OHM_IS_KEYSTORE (object));
+ keystore = OHM_KEYSTORE (object);
+
+ g_debug ("Finalizing ohm-keystore");
G_OBJECT_CLASS (ohm_keystore_parent_class)->finalize (object);
}
+
/**
* ohm_keystore_class_init:
**/
@@ -160,7 +175,8 @@ static void
ohm_keystore_class_init (OhmKeystoreClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = ohm_keystore_finalize;
+ object_class->finalize = ohm_keystore_finalize;
+ object_class->dispose = ohm_keystore_dispose;
signals [KEY_CHANGED] =
g_signal_new ("key-changed",
diff --git a/ohmd/ohm-manager.c b/ohmd/ohm-manager.c
index fcbdc77..df52384 100644
--- a/ohmd/ohm-manager.c
+++ b/ohmd/ohm-manager.c
@@ -48,6 +48,7 @@
static void ohm_manager_class_init (OhmManagerClass *klass);
static void ohm_manager_init (OhmManager *manager);
+static void ohm_manager_dispose (GObject *object);
static void ohm_manager_finalize (GObject *object);
#define OHM_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), OHM_TYPE_MANAGER, OhmManagerPrivate))
@@ -132,7 +133,8 @@ ohm_manager_class_init (OhmManagerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = ohm_manager_finalize;
+ object_class->finalize = ohm_manager_finalize;
+ object_class->dispose = ohm_manager_dispose;
signals [ON_AC_CHANGED] =
g_signal_new ("on-ac-changed",
@@ -180,13 +182,13 @@ ohm_manager_init (OhmManager *manager)
}
/**
- * ohm_manager_finalize:
- * @object: The object to finalize
+ * ohm_manager_dispose:
+ * @object: The object to dispose
*
- * Finalise the manager, by unref'ing all the depending modules.
+ * unref all objects we're holding
**/
static void
-ohm_manager_finalize (GObject *object)
+ohm_manager_dispose (GObject *object)
{
OhmManager *manager;
@@ -199,6 +201,25 @@ ohm_manager_finalize (GObject *object)
g_object_unref (manager->priv->keystore);
g_object_unref (manager->priv->conf);
+ G_OBJECT_CLASS (ohm_manager_parent_class)->dispose (object);
+}
+
+/**
+ * ohm_manager_finalize:
+ * @object: The object to finalize
+ *
+ * Finalise the manager
+ **/
+static void
+ohm_manager_finalize (GObject *object)
+{
+ OhmManager *manager;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (OHM_IS_MANAGER (object));
+ manager = OHM_MANAGER (object);
+
+ g_debug ("Finalizing ohm_manager");
G_OBJECT_CLASS (ohm_manager_parent_class)->finalize (object);
}