[glib/wip/gcleanup: 6/42] gtypemodule: Allow GTypeModule to be finalized



commit df5732fa52c05801a72eff6b58d1944d513542b0
Author: Stef Walter <stefw gnome org>
Date:   Thu Nov 7 22:56:11 2013 +0100

    gtypemodule: Allow GTypeModule to be finalized
    
    This is used by the cleanup code.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=711778

 gobject/gtypemodule.c        |   12 ++++++------
 gobject/tests/dynamictests.c |   10 ++++++++++
 2 files changed, 16 insertions(+), 6 deletions(-)
---
diff --git a/gobject/gtypemodule.c b/gobject/gtypemodule.c
index 6e55456..57ed2df 100644
--- a/gobject/gtypemodule.c
+++ b/gobject/gtypemodule.c
@@ -105,13 +105,13 @@ static void
 g_type_module_dispose (GObject *object)
 {
   GTypeModule *module = G_TYPE_MODULE (object);
-  
-  if (module->type_infos || module->interface_infos)
-    {
-      g_warning (G_STRLOC ": unsolicitated invocation of g_object_run_dispose() on GTypeModule");
 
-      g_object_ref (object);
-    }
+  /* The types themselves will be cleaned up separately */
+  g_slist_free_full (module->type_infos, g_free);
+  module->type_infos = NULL;
+
+  g_slist_free_full (module->interface_infos, g_free);
+  module->interface_infos = NULL;
 
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }
diff --git a/gobject/tests/dynamictests.c b/gobject/tests/dynamictests.c
index e222d34..737f18f 100644
--- a/gobject/tests/dynamictests.c
+++ b/gobject/tests/dynamictests.c
@@ -223,6 +223,8 @@ test_multithreaded_dynamic_type_init (void)
   for (i = 0; i < N_THREADS; i++) {
     g_thread_join (threads[i]);
   }
+
+  g_object_unref (module);
 }
 
 enum
@@ -344,6 +346,7 @@ static void
 test_dynamic_interface_properties (void)
 {
   GTypeModule *module;
+  gpointer check;
   DynObj *obj;
   gint val;
 
@@ -354,7 +357,14 @@ test_dynamic_interface_properties (void)
   g_object_get (obj, "foo", &val, NULL);
   g_assert_cmpint (val, ==, 1);
 
+  check = obj;
+  g_object_add_weak_pointer (check, &check);
+
   g_object_unref (obj);
+
+  g_assert (check == NULL);
+
+  g_object_unref (module);
 }
 
 int


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]