[glib/wip/free: 5/6] redo interface pspec cleanup with set_qdata_full
- From: Dan Winship <danw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/wip/free: 5/6] redo interface pspec cleanup with set_qdata_full
- Date: Thu, 31 Oct 2013 15:34:01 +0000 (UTC)
commit 27f34bc1a3cf658929735108d927b710a24592f1
Author: Dan Winship <danw gnome org>
Date: Wed Aug 29 10:32:08 2012 -0400
redo interface pspec cleanup with set_qdata_full
gobject/gobject.c | 41 +++++++++++++++++++++++++++++------------
gobject/gtype-private.h | 4 ----
gobject/gtype.c | 20 +++++---------------
3 files changed, 34 insertions(+), 31 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 80a652e..f01971a 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -197,6 +197,7 @@ static GQuark quark_closure_array = 0;
static GQuark quark_weak_refs = 0;
static GQuark quark_toggle_refs = 0;
static GQuark quark_notify_queue;
+static GQuark quark_interface_pspecs;
static GParamSpecPool *pspec_pool = NULL;
static gulong gobject_signals[LAST_SIGNAL] = { 0, };
static guint (*floating_flag_handler) (GObject*, gint) = object_floating_flag_handler;
@@ -440,18 +441,7 @@ g_object_base_class_init (GObjectClass *class)
}
static void
-g_object_base_class_finalize (GObjectClass *class)
-{
- _g_signals_destroy (G_OBJECT_CLASS_TYPE (class));
-
- g_slist_free (class->construct_properties);
- class->construct_properties = NULL;
-
- _g_object_release_resources_owned_by (G_OBJECT_CLASS_TYPE (class));
-}
-
-void
-_g_object_release_resources_owned_by (GType type)
+_g_object_type_free_pspecs (GType type)
{
GList *list, *node;
@@ -468,6 +458,17 @@ _g_object_release_resources_owned_by (GType type)
}
static void
+g_object_base_class_finalize (GObjectClass *class)
+{
+ _g_signals_destroy (G_OBJECT_CLASS_TYPE (class));
+
+ g_slist_free (class->construct_properties);
+ class->construct_properties = NULL;
+
+ _g_object_type_free_pspecs (G_OBJECT_CLASS_TYPE (class));
+}
+
+static void
g_object_do_class_init (GObjectClass *class)
{
/* read the comment about typedef struct CArray; on why not to change this quark */
@@ -477,6 +478,7 @@ g_object_do_class_init (GObjectClass *class)
quark_weak_locations = g_quark_from_static_string ("GObject-weak-locations");
quark_toggle_refs = g_quark_from_static_string ("GObject-toggle-references");
quark_notify_queue = g_quark_from_static_string ("GObject-notify-queue");
+ quark_interface_pspecs = g_quark_from_static_string ("GObject-interface-pspecs");
pspec_pool = g_param_spec_pool_new (TRUE);
class->constructor = g_object_constructor;
@@ -714,6 +716,14 @@ g_object_class_install_properties (GObjectClass *oclass,
}
}
+static void
+free_interface_type_pspecs (gpointer data)
+{
+ GType type = GPOINTER_TO_SIZE (data);
+
+ _g_object_type_free_pspecs (type);
+}
+
/**
* g_object_interface_install_property:
* @g_iface: any interface vtable for the interface, or the default
@@ -755,6 +765,13 @@ g_object_interface_install_property (gpointer g_iface,
g_return_if_fail (pspec->flags & G_PARAM_WRITABLE);
install_property_internal (iface_class->g_type, 0, pspec);
+
+ if (!g_type_get_qdata (iface_class->g_type, quark_interface_pspecs))
+ {
+ g_type_set_qdata_full (iface_class->g_type, quark_interface_pspecs,
+ GSIZE_TO_POINTER (iface_class->g_type),
+ free_interface_type_pspecs);
+ }
}
/**
diff --git a/gobject/gtype-private.h b/gobject/gtype-private.h
index f385dec..33c7641 100644
--- a/gobject/gtype-private.h
+++ b/gobject/gtype-private.h
@@ -78,10 +78,6 @@ void _g_closure_invoke_va (GClosure *closure,
int n_params,
GType *param_types);
-
-/* for gtype.c */
-void _g_object_release_resources_owned_by (GType type);
-
G_END_DECLS
#endif /* __G_TYPE_PRIVATE_H__ */
diff --git a/gobject/gtype.c b/gobject/gtype.c
index fb6ec1e..892bd3a 100644
--- a/gobject/gtype.c
+++ b/gobject/gtype.c
@@ -4496,15 +4496,6 @@ type_data_finalize (TypeNode *node)
tdata->iface.dflt_finalize (tdata->iface.dflt_vtable, (gpointer) tdata->iface.dflt_data);
if (tdata->iface.vtable_finalize_base)
tdata->iface.vtable_finalize_base (tdata->iface.dflt_vtable);
-
- /* FIXME: This is awful...
- *
- * Interfaces might do g_object_interface_install_property() in their
- * base_init, which means that the GTypeInterface owns this GParamSpec.
- * However, the GParamSpecPool is owned by GObject... and the interface'
- * GParamSpecs need to be released when it goes away.
- */
- _g_object_release_resources_owned_by (NODE_TYPE (node));
}
}
@@ -4834,12 +4825,6 @@ g_type_cleanup (void)
type_data_finalize (node);
}
- _g_signal_cleanup ();
- _g_param_spec_types_cleanup ();
- _g_object_type_cleanup ();
- _g_param_type_cleanup ();
- _g_value_c_cleanup ();
-
g_clear_pointer (&static_class_cache_funcs, g_free);
g_clear_pointer (&static_iface_check_funcs, g_free);
@@ -4925,6 +4910,11 @@ g_type_cleanup (void)
g_clear_pointer (&static_type_nodes_ht, g_hash_table_unref);
_g_atomic_array_cleanup ();
+ _g_signal_cleanup ();
+ _g_param_spec_types_cleanup ();
+ _g_object_type_cleanup ();
+ _g_param_type_cleanup ();
+ _g_value_c_cleanup ();
g_rw_lock_clear (&type_rw_lock);
g_rec_mutex_clear (&class_init_rec_mutex);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]