seahorse r2767 - in trunk: . libseahorse
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: seahorse r2767 - in trunk: . libseahorse
- Date: Fri, 6 Feb 2009 03:34:44 +0000 (UTC)
Author: nnielsen
Date: Fri Feb 6 03:34:44 2009
New Revision: 2767
URL: http://svn.gnome.org/viewvc/seahorse?rev=2767&view=rev
Log:
Ref objects while the context is being destroyed.
So that removing an object that was removed by another object doesn't
crash. We need a new ownership model....
Modified:
trunk/ChangeLog
trunk/libseahorse/seahorse-context.c
trunk/libseahorse/seahorse-context.h
Modified: trunk/libseahorse/seahorse-context.c
==============================================================================
--- trunk/libseahorse/seahorse-context.c (original)
+++ trunk/libseahorse/seahorse-context.c Fri Feb 6 03:34:44 2009
@@ -134,9 +134,9 @@
}
static void
-hash_to_slist (gpointer object, gpointer value, gpointer user_data)
+hash_to_ref_slist (gpointer object, gpointer value, gpointer user_data)
{
- *((GSList**)user_data) = g_slist_prepend (*((GSList**)user_data), value);
+ *((GSList**)user_data) = g_slist_prepend (*((GSList**)user_data), g_object_ref (value));
}
/* release all references */
@@ -150,9 +150,11 @@
/* Release all the objects */
objects = NULL;
- g_hash_table_foreach (sctx->pv->objects_by_source, hash_to_slist, &objects);
- for (l = objects; l; l = g_slist_next (l))
- seahorse_context_remove_object (sctx, l->data);
+ g_hash_table_foreach (sctx->pv->objects_by_source, hash_to_ref_slist, &objects);
+ for (l = objects; l; l = g_slist_next (l)) {
+ seahorse_context_remove_object (sctx, l->data);
+ g_object_unref (l->data);
+ }
g_slist_free (objects);
/* Gconf notification */
@@ -705,6 +707,26 @@
return seahorse_context_find_objects_full (sctx, &pred);
}
+static void
+verify_each_object (gpointer key, gpointer value, gpointer user_data)
+{
+ gpointer k;
+
+ g_assert (SEAHORSE_IS_OBJECT (value));
+ k = hashkey_by_source (seahorse_object_get_source (value),
+ seahorse_object_get_id (value));
+ g_assert (k == key);
+}
+
+void
+seahorse_context_verify_objects (SeahorseContext *self)
+{
+ if (!self)
+ self = seahorse_context_for_app ();
+ g_return_if_fail (SEAHORSE_IS_CONTEXT (self));
+ g_hash_table_foreach (self->pv->objects_by_source, verify_each_object, self);
+}
+
void
seahorse_context_remove_object (SeahorseContext *sctx, SeahorseObject *sobj)
{
Modified: trunk/libseahorse/seahorse-context.h
==============================================================================
--- trunk/libseahorse/seahorse-context.h (original)
+++ trunk/libseahorse/seahorse-context.h Fri Feb 6 03:34:44 2009
@@ -161,6 +161,8 @@
SeahorseObjectFunc func,
gpointer user_data);
+void seahorse_context_verify_objects (SeahorseContext *self);
+
void seahorse_context_remove_object (SeahorseContext *sctx,
struct _SeahorseObject *sobj);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]