[glibmm/glibmm-2-36] Revert the "Implement derived interface properties" changes.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm/glibmm-2-36] Revert the "Implement derived interface properties" changes.
- Date: Thu, 2 May 2013 07:05:42 +0000 (UTC)
commit 45b618d1ddd86bb1e36581a44d594cd32250cb7c
Author: Murray Cumming <murrayc murrayc com>
Date: Tue Apr 30 09:18:53 2013 +0200
Revert the "Implement derived interface properties" changes.
This new feature should not have been in the stable branch.
It remains in git master, for glibmm 2.37/38.
ChangeLog | 7 ++++
glib/glibmm/class.cc | 23 +-------------
glib/glibmm/class.h | 12 -------
glib/glibmm/interface.cc | 42 ++----------------------
glib/glibmm/property.cc | 79 +++++++++-------------------------------------
5 files changed, 27 insertions(+), 136 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9a4c575..00780be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-04-30 Murray Cumming <murrayc murrayc com>
+
+ Revert the "Implement derived interface properties" changes.
+
+ This new feature should not have been in the stable branch.
+ It remains in git master, for glibmm 2.37/38.
+
2.36.1:
2013-04-29 José Alburquerque <jaalburquerque gmail com>
diff --git a/glib/glibmm/class.cc b/glib/glibmm/class.cc
index c31a834..5cb9130 100644
--- a/glib/glibmm/class.cc
+++ b/glib/glibmm/class.cc
@@ -131,28 +131,6 @@ GType Class::clone_custom_type(const char* custom_type_name) const
return custom_type;
}
-// Initialize the static quark to store/get custom type properties.
-GQuark Class::properties_quark = g_quark_from_string("gtkmm_CustomObject_properties");
-
-// static
-void Class::interface_finalize_function(void* g_iface, void*)
-{
- const GType gtype = G_TYPE_FROM_CLASS(g_iface);
-
- // 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));
-
- if(props)
- {
- for(properties_type::size_type i = 0; i < props->size(); i++)
- {
- g_value_unset((*props)[i]);
- g_free((*props)[i]);
- }
- delete props;
- }
-}
-
// static
void Class::custom_class_init_function(void* g_class, void* class_data)
{
@@ -171,3 +149,4 @@ void Class::custom_class_init_function(void* g_class, void* class_data)
}
} // namespace Glib
+
diff --git a/glib/glibmm/class.h b/glib/glibmm/class.h
index 7092d50..2e7345d 100644
--- a/glib/glibmm/class.h
+++ b/glib/glibmm/class.h
@@ -25,7 +25,6 @@
#include <glib-object.h>
#include <glibmmconfig.h> //Include this here so that the /private/*.h classes have access to
GLIBMM_VFUNCS_ENABLED
-#include <vector> //For properties that custom types might override.
#ifndef DOXYGEN_SHOULD_SKIP_THIS
@@ -67,19 +66,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_init_function(void* g_class, void* class_data);
-
-public:
-#ifndef DOXYGEN_SHOULD_SKIP_THIS
- // The type that holds the values of the properties of custom types.
- typedef std::vector<GValue*> properties_type;
- // The quark used for storing/getting the properties of custom types.
- static GQuark properties_quark;
-#endif
};
inline
diff --git a/glib/glibmm/interface.cc b/glib/glibmm/interface.cc
index 5a20750..c8fde23 100644
--- a/glib/glibmm/interface.cc
+++ b/glib/glibmm/interface.cc
@@ -19,7 +19,6 @@
*/
#include <glibmm/interface.h>
-#include <glibmm/class.h>
#include <glibmm/private/interface_p.h>
@@ -36,7 +35,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
};
@@ -59,44 +58,11 @@ Interface::Interface(const Interface_Class& interface_class)
if(custom_type_name_ && !is_anonymous_custom_())
{
- GObjectClass *const instance_class = G_OBJECT_GET_CLASS(gobject_);
- const GType iface_type = interface_class.get_type();
+ void *const instance_class = G_OBJECT_GET_CLASS(gobject_);
- if(!g_type_interface_peek(instance_class, iface_type))
+ if(!g_type_interface_peek(instance_class, interface_class.get_type()))
{
- void* const g_iface = g_type_default_interface_ref(iface_type);
-
- // Override the properties of the derived interface, if any.
-
- const GType custom_type = G_OBJECT_CLASS_TYPE(instance_class);
- Class::properties_type* props = static_cast<Class::properties_type*>(g_type_get_qdata(custom_type,
Class::properties_quark));
-
- if(!props)
- {
- props = new Class::properties_type();
- g_type_set_qdata(custom_type, Class::properties_quark, props);
- }
-
- const guint n_existing_props = props->size();
-
- guint n_iface_props = 0;
- GParamSpec** iface_props = g_object_interface_list_properties(g_iface, &n_iface_props);
-
- for(guint p = 0; p < n_iface_props; p++)
- {
- GValue* g_value = g_new0(GValue, 1);
- g_value_init(g_value, iface_props[p]->value_type);
- props->push_back(g_value);
-
- const gchar* prop_name = g_param_spec_get_name(iface_props[p]);
- GParamSpec* new_spec = g_param_spec_override(prop_name, iface_props[p]);
- g_object_class_install_property(instance_class, p + 1 + n_existing_props, new_spec);
- }
-
- interface_class.add_interface(custom_type);
-
- g_type_default_interface_unref(g_iface);
- g_free(iface_props);
+ interface_class.add_interface(G_OBJECT_CLASS_TYPE(instance_class));
}
}
}
diff --git a/glib/glibmm/property.cc b/glib/glibmm/property.cc
index 0ae0345..3b73b6b 100644
--- a/glib/glibmm/property.cc
+++ b/glib/glibmm/property.cc
@@ -22,7 +22,6 @@
#include <glibmm/object.h>
-#include <glibmm/class.h>
#include <cstddef>
// Temporary hack till GLib gets fixed.
@@ -107,68 +106,31 @@ namespace Glib
void custom_get_property_callback(GObject* object, unsigned int property_id,
GValue* value, GParamSpec* param_spec)
{
- // If the id is zero there is no property to get.
- g_return_if_fail(property_id != 0);
-
- GType custom_type = G_OBJECT_TYPE(object);
-
- Class::properties_type* props = static_cast<Class::properties_type*>(g_type_get_qdata(custom_type,
Class::properties_quark));
- Class::properties_type::size_type props_size = 0;
-
- if(props) props_size = props->size();
-
- if(property_id <= props_size)
+ if(Glib::ObjectBase *const wrapper = Glib::ObjectBase::_get_current_wrapper(object))
{
- g_value_copy((*props)[property_id - 1], value);
- }
- else
- {
- if(Glib::ObjectBase *const wrapper = Glib::ObjectBase::_get_current_wrapper(object))
- {
- PropertyBase& property =
- property_from_id(*wrapper, property_id - props_size);
+ PropertyBase& property = property_from_id(*wrapper, property_id);
- if((property.object_ == wrapper) && (property.param_spec_ == param_spec))
- g_value_copy(property.value_.gobj(), value);
- else
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, param_spec);
- }
+ if((property.object_ == wrapper) && (property.param_spec_ == param_spec))
+ g_value_copy(property.value_.gobj(), value);
+ else
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, param_spec);
}
}
void custom_set_property_callback(GObject* object, unsigned int property_id,
const GValue* value, GParamSpec* param_spec)
{
- // If the id is zero there is no property to get.
- g_return_if_fail(property_id != 0);
-
- GType custom_type = G_OBJECT_TYPE(object);
-
- Class::properties_type* props = static_cast<Class::properties_type*>(g_type_get_qdata(custom_type,
Class::properties_quark));
- Class::properties_type::size_type props_size = 0;
-
- if(props) props_size = props->size();
-
- if(property_id <= props_size)
- {
- g_value_copy(value, (*props)[property_id - 1]);
- g_object_notify(object, g_param_spec_get_name(param_spec));
- }
- else
+ if(Glib::ObjectBase *const wrapper = Glib::ObjectBase::_get_current_wrapper(object))
{
- if(Glib::ObjectBase *const wrapper = Glib::ObjectBase::_get_current_wrapper(object))
+ PropertyBase& property = property_from_id(*wrapper, property_id);
+
+ if((property.object_ == wrapper) && (property.param_spec_ == param_spec))
{
- PropertyBase& property =
- property_from_id(*wrapper, property_id - props_size);
-
- if((property.object_ == wrapper) && (property.param_spec_ == param_spec))
- {
- g_value_copy(value, property.value_.gobj());
- g_object_notify(object, g_param_spec_get_name(param_spec));
- }
- else
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, param_spec);
+ g_value_copy(value, property.value_.gobj());
+ g_object_notify(object, g_param_spec_get_name(param_spec));
}
+ else
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, param_spec);
}
}
@@ -209,18 +171,7 @@ void PropertyBase::install_property(GParamSpec* param_spec)
{
g_return_if_fail(param_spec != 0);
- // Ensure that there would not be id clashes with possible existing
- // properties overridden from implemented interfaces if dealing with a custom
- // type by offsetting the generated id with the number of already existing
- // properties.
-
- GType gtype = G_OBJECT_TYPE(object_->gobj());
- Class::properties_type* props = static_cast<Class::properties_type*>(g_type_get_qdata(gtype,
Class::properties_quark));
-
- Class::properties_type::size_type props_size = 0;
- if(props) props_size = props->size();
-
- const unsigned int property_id = property_to_id(*object_, *this) + props_size;
+ const unsigned int property_id = property_to_id(*object_, *this);
g_object_class_install_property(G_OBJECT_GET_CLASS(object_->gobj()), property_id, param_spec);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]