[Galago-commits] r2701 - in trunk/libgalago: . libgalago
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Tue Apr 11 01:35:14 PDT 2006
Author: chipx86
Date: 2006-04-11 01:35:10 -0700 (Tue, 11 Apr 2006)
New Revision: 2701
Modified:
trunk/libgalago/ChangeLog
trunk/libgalago/libgalago/galago-account.c
trunk/libgalago/libgalago/galago-context.c
trunk/libgalago/libgalago/galago-object.c
trunk/libgalago/libgalago/galago-person.c
Log:
- Move back to galago_object_destroy(). This function now disposes and unrefs. This seems to fix all the reference issues I've had in C and Python. Hopefully this means the problem is now gone. Probably not :)
- Made GalagoObject's dispose and finalize a bit smarter. We now remove the object from the context in dispose, and clean up the rest in finalize.
Modified: trunk/libgalago/ChangeLog
===================================================================
--- trunk/libgalago/ChangeLog 2006-04-11 07:22:00 UTC (rev 2700)
+++ trunk/libgalago/ChangeLog 2006-04-11 08:35:10 UTC (rev 2701)
@@ -1,3 +1,16 @@
+Tue Apr 11 01:31:51 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
+
+ * libgalago/galago-account.c:
+ * libgalago/galago-context.c:
+ * libgalago/galago-object.c:
+ * libgalago/galago-person.c:
+ - Move back to galago_object_destroy(). This function now disposes and
+ unrefs. This seems to fix all the reference issues I've had in C and
+ Python. Hopefully this means the problem is now gone. Probably not :)
+ - Made GalagoObject's dispose and finalize a bit smarter. We now
+ remove the object from the context in dispose, and clean up the
+ rest in finalize.
+
Tue Apr 11 00:20:37 PDT 2006 Christian Hammond <chipx86 at chipx86.com>
* libgalago/galago-account.c:
Modified: trunk/libgalago/libgalago/galago-account.c
===================================================================
--- trunk/libgalago/libgalago/galago-account.c 2006-04-11 07:22:00 UTC (rev 2700)
+++ trunk/libgalago/libgalago/galago-account.c 2006-04-11 08:35:10 UTC (rev 2701)
@@ -923,10 +923,8 @@
{
GalagoPresence *old_presence = account->priv->presence;
account->priv->presence = NULL;
+ galago_object_destroy(GALAGO_OBJECT(old_presence));
- if (!GALAGO_OBJECT_HAS_FLAG(old_presence, GALAGO_OBJECT_IN_DESTRUCTION))
- g_object_unref(G_OBJECT(old_presence));
-
emit_deleted = (presence == NULL);
}
Modified: trunk/libgalago/libgalago/galago-context.c
===================================================================
--- trunk/libgalago/libgalago/galago-context.c 2006-04-11 07:22:00 UTC (rev 2700)
+++ trunk/libgalago/libgalago/galago-context.c 2006-04-11 08:35:10 UTC (rev 2701)
@@ -168,34 +168,20 @@
}
static void
-remove_object(GObject *object)
-{
- printf("Unreffing..\n");
- g_object_unref(G_OBJECT(object));
-
- if (object->ref_count > 0)
- {
- printf("Object %p (%s) has ref count of %d\n",
- object, G_OBJECT_TYPE_NAME(object), object->ref_count);
- }
-}
-
-static void
galago_context_destroy(GalagoObject *object)
{
GalagoContext *context = GALAGO_CONTEXT(object);
if (context->priv != NULL)
{
- printf("Releasing refs..\n");
g_list_foreach(context->priv->local.services,
- (GFunc)remove_object, NULL);
+ (GFunc)galago_object_destroy, NULL);
g_list_foreach(context->priv->remote.services,
- (GFunc)remove_object, NULL);
+ (GFunc)galago_object_destroy, NULL);
g_list_foreach(context->priv->local.people,
- (GFunc)remove_object, NULL);
+ (GFunc)galago_object_destroy, NULL);
g_list_foreach(context->priv->remote.people,
- (GFunc)remove_object, NULL);
+ (GFunc)galago_object_destroy, NULL);
g_hash_table_destroy(context->priv->services_table);
g_hash_table_destroy(context->priv->people_table);
@@ -737,9 +723,9 @@
{
case GALAGO_LOCAL:
g_list_foreach(context->priv->local.services,
- (GFunc)remove_object, NULL);
+ (GFunc)galago_object_destroy, NULL);
g_list_foreach(context->priv->local.people,
- (GFunc)remove_object, NULL);
+ (GFunc)galago_object_destroy, NULL);
context->priv->local.services = NULL;
context->priv->local.people = NULL;
@@ -747,9 +733,9 @@
case GALAGO_REMOTE:
g_list_foreach(context->priv->remote.services,
- (GFunc)remove_object, NULL);
+ (GFunc)galago_object_destroy, NULL);
g_list_foreach(context->priv->remote.people,
- (GFunc)remove_object, NULL);
+ (GFunc)galago_object_destroy, NULL);
context->priv->remote.services = NULL;
context->priv->remote.people = NULL;
Modified: trunk/libgalago/libgalago/galago-object.c
===================================================================
--- trunk/libgalago/libgalago/galago-object.c 2006-04-11 07:22:00 UTC (rev 2700)
+++ trunk/libgalago/libgalago/galago-object.c 2006-04-11 08:35:10 UTC (rev 2701)
@@ -34,6 +34,7 @@
GalagoOrigin origin;
GHashTable *attrs_table;
GList *attrs_list;
+ gboolean in_context : 1;
gboolean watched : 1;
};
@@ -156,6 +157,14 @@
g_signal_emit(object, signals[DESTROY], 0);
+ if (object->priv->in_context)
+ {
+ galago_context_push(object->priv->context);
+ galago_context_remove_object(object);
+ galago_context_pop();
+ object->priv->in_context = FALSE;
+ }
+
GALAGO_OBJECT_UNSET_FLAGS(object, GALAGO_OBJECT_IN_DESTRUCTION);
}
@@ -168,22 +177,19 @@
{
GalagoObject *object = GALAGO_OBJECT(gobject);
- printf("Finalizing object %p (%s)\n", gobject, G_OBJECT_TYPE_NAME(gobject));
-
if (object->priv != NULL)
{
if (object->priv->dbus_path != NULL)
{
- galago_context_push(object->priv->context);
- galago_context_remove_object(object);
- galago_context_pop();
g_free(object->priv->dbus_path);
+ object->priv->dbus_path = NULL;
}
if (object->priv->attrs_table != NULL)
g_hash_table_destroy(object->priv->attrs_table);
g_free(object->priv);
+ object->priv = NULL;
}
if (G_OBJECT_CLASS(parent_class)->finalize != NULL)
@@ -264,11 +270,11 @@
g_return_if_fail(object != NULL);
g_return_if_fail(GALAGO_IS_OBJECT(object));
- g_object_unref(G_OBJECT(object));
-#if 0
if (!GALAGO_OBJECT_HAS_FLAG(object, GALAGO_OBJECT_IN_DESTRUCTION))
+ {
g_object_run_dispose(G_OBJECT(object));
-#endif
+ g_object_unref(G_OBJECT(object));
+ }
}
const gchar *
@@ -312,14 +318,18 @@
if (object->priv->dbus_path != NULL)
{
galago_context_remove_object(object);
+ object->priv->in_context = FALSE;
g_free(object->priv->dbus_path);
}
object->priv->dbus_path = (obj_path != NULL ? g_strdup(obj_path) : NULL);
- if (object->priv->dbus_path != NULL)
+ if (object->priv->dbus_path != NULL && !object->priv->in_context)
+ {
galago_context_add_object(object);
+ object->priv->in_context = TRUE;
+ }
galago_context_pop();
}
Modified: trunk/libgalago/libgalago/galago-person.c
===================================================================
--- trunk/libgalago/libgalago/galago-person.c 2006-04-11 07:22:00 UTC (rev 2700)
+++ trunk/libgalago/libgalago/galago-person.c 2006-04-11 08:35:10 UTC (rev 2701)
@@ -527,7 +527,7 @@
{
GalagoImage *old_photo = person->priv->photo;
person->priv->photo = NULL;
- g_object_unref(G_OBJECT(old_photo));
+ galago_object_destroy(GALAGO_OBJECT(old_photo));
}
person->priv->photo = photo;
More information about the galago-commits
mailing list