summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Alburquerque <jaalburquerque@gmail.com>2013-05-14 16:22:17 -0400
committerJosé Alburquerque <jaalburquerque@gmail.com>2013-05-14 16:23:26 -0400
commit1826a955cc607527ebb47eecf701aa5e28fdc1ef (patch)
treead8eecb4f42d16ba99bf4a8a2a2164963ea6c8d4
parenta5edc6add97ff030f89d2bd2e39d8ec5b453ffb0 (diff)
downloadglibmm-1826a955cc607527ebb47eecf701aa5e28fdc1ef.tar.gz
Custom Interface Properties: Use base finalize function to free data.
* glib/glibmm/class.cc (Class::clone_custom_type): Specify a custom base finalize function for the custom type which would free the properties data that might exist due to properties of implemented interfaces being overridden. This is better than having an interface finalize function because the custom type could implement several interfaces which would mean that the interface finalize function would execute more than once as opposed to just once for the base finalize function. * glib/glibmm/class.h (Class::interface_finalize_function): Replace with Class::custom_class_base_finalize_function(). * glib/glibmm/interface.cc (Interface_Class::add_interface): Do not specify a custom interface finalize function. (Interface::Interface(const Interface_Class&): Also initialize the property GValues using g_param_value_set_default() so that they are initialized with the default values of the properties and not just the default value of the GValue type. Bug #697229.
-rw-r--r--ChangeLog25
-rw-r--r--glib/glibmm/class.cc6
-rw-r--r--glib/glibmm/class.h4
-rw-r--r--glib/glibmm/interface.cc3
4 files changed, 31 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index bb6e5712..508ec672 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2013-05-14 José Alburquerque <jaalburquerque@gmail.com>
+
+ Custom Interface Properties: Use base finalize function to free data.
+
+ * glib/glibmm/class.cc (Class::clone_custom_type): Specify a custom
+ base finalize function for the custom type which would free the
+ properties data that might exist due to properties of implemented
+ interfaces being overridden. This is better than having an interface
+ finalize function because the custom type could implement several
+ interfaces which would mean that the interface finalize function would
+ execute more than once as opposed to just once for the base finalize
+ function.
+ * glib/glibmm/class.h (Class::interface_finalize_function): Replace
+ with Class::custom_class_base_finalize_function().
+
+ * glib/glibmm/interface.cc (Interface_Class::add_interface): Do not
+ specify a custom interface finalize function.
+
+ (Interface::Interface(const Interface_Class&): Also initialize the
+ property GValues using g_param_value_set_default() so that they are
+ initialized with the default values of the properties and not just the
+ default value of the GValue type.
+
+ Bug #697229.
+
2013-05-07 José Alburquerque <jaalburquerque@gmail.com>
UnixSocketAddress: Add the "path-as-array" property.
diff --git a/glib/glibmm/class.cc b/glib/glibmm/class.cc
index c31a834b..3b6da41d 100644
--- a/glib/glibmm/class.cc
+++ b/glib/glibmm/class.cc
@@ -114,7 +114,7 @@ GType Class::clone_custom_type(const char* custom_type_name) const
{
class_size,
0, // base_init
- 0, // base_finalize
+ &Class::custom_class_base_finalize_function, // base_finalize
&Class::custom_class_init_function,
0, // class_finalize
this, // class_data
@@ -135,9 +135,9 @@ GType Class::clone_custom_type(const char* custom_type_name) const
GQuark Class::properties_quark = g_quark_from_string("gtkmm_CustomObject_properties");
// static
-void Class::interface_finalize_function(void* g_iface, void*)
+void Class::custom_class_base_finalize_function(void* g_class)
{
- const GType gtype = G_TYPE_FROM_CLASS(g_iface);
+ const GType gtype = G_TYPE_FROM_CLASS(g_class);
// Free the data related to the properties for the custom type, if any.
properties_type* props = static_cast<properties_type*>(g_type_get_qdata(gtype, properties_quark));
diff --git a/glib/glibmm/class.h b/glib/glibmm/class.h
index 7092d506..dbd7c581 100644
--- a/glib/glibmm/class.h
+++ b/glib/glibmm/class.h
@@ -67,10 +67,8 @@ protected:
*/
void register_derived_type(GType base_type, GTypeModule* module);
-protected:
- static void interface_finalize_function(void* g_iface, void* iface_data);
-
private:
+ static void custom_class_base_finalize_function(void* g_class);
static void custom_class_init_function(void* g_class, void* class_data);
public:
diff --git a/glib/glibmm/interface.cc b/glib/glibmm/interface.cc
index d55b9bd7..7183bc76 100644
--- a/glib/glibmm/interface.cc
+++ b/glib/glibmm/interface.cc
@@ -36,7 +36,7 @@ void Interface_Class::add_interface(GType instance_type) const
const GInterfaceInfo interface_info =
{
class_init_func_,
- &Class::interface_finalize_function, // interface_finalize
+ 0, // interface_finalize
0, // interface_data
};
@@ -86,6 +86,7 @@ Interface::Interface(const Interface_Class& interface_class)
{
GValue* g_value = g_new0(GValue, 1);
g_value_init(g_value, iface_props[p]->value_type);
+ g_param_value_set_default(iface_props[p], g_value);
props->push_back(g_value);
const gchar* prop_name = g_param_spec_get_name(iface_props[p]);