libgimpconfig/gimpconfig-deserialize.c (gimp_config_deserialize_property)

2006-08-08  Sven Neumann  <sven@gimp.org>

	* libgimpconfig/gimpconfig-deserialize.c
	(gimp_config_deserialize_property)
	* libgimpconfig/gimpconfig-serialize.c
	(gimp_config_serialize_property): check if the properties
	owner_type is an object type before calling g_type_class_peek().
This commit is contained in:
Sven Neumann
2006-08-08 12:29:48 +00:00
committed by Sven Neumann
parent 29a494d146
commit 44594ae2e0
3 changed files with 56 additions and 42 deletions

View File

@ -1,3 +1,11 @@
2006-08-08 Sven Neumann <sven@gimp.org>
* libgimpconfig/gimpconfig-deserialize.c
(gimp_config_deserialize_property)
* libgimpconfig/gimpconfig-serialize.c
(gimp_config_serialize_property): check if the properties
owner_type is an object type before calling g_type_class_peek().
2006-08-08 Sven Neumann <sven@gimp.org> 2006-08-08 Sven Neumann <sven@gimp.org>
* app/tools/gimprectangleoptions.c * app/tools/gimprectangleoptions.c

View File

@ -212,8 +212,7 @@ gimp_config_deserialize_property (GimpConfig *config,
GScanner *scanner, GScanner *scanner,
gint nest_level) gint nest_level)
{ {
GTypeClass *owner_class; GimpConfigInterface *config_iface = NULL;
GimpConfigInterface *config_iface;
GimpConfigInterface *parent_iface = NULL; GimpConfigInterface *parent_iface = NULL;
GParamSpec *prop_spec; GParamSpec *prop_spec;
GTokenType token = G_TOKEN_RIGHT_PAREN; GTokenType token = G_TOKEN_RIGHT_PAREN;
@ -226,7 +225,9 @@ gimp_config_deserialize_property (GimpConfig *config,
g_value_init (&value, prop_spec->value_type); g_value_init (&value, prop_spec->value_type);
owner_class = g_type_class_peek (prop_spec->owner_type); if (G_TYPE_IS_OBJECT (prop_spec->owner_type))
{
GTypeClass *owner_class = g_type_class_peek (prop_spec->owner_type);
config_iface = g_type_interface_peek (owner_class, GIMP_TYPE_CONFIG); config_iface = g_type_interface_peek (owner_class, GIMP_TYPE_CONFIG);
@ -234,7 +235,8 @@ gimp_config_deserialize_property (GimpConfig *config,
* which implements it is param_spec->owner_type's class. * which implements it is param_spec->owner_type's class.
* *
* Therefore, we ask param_spec->owner_type's immediate parent class * Therefore, we ask param_spec->owner_type's immediate parent class
* for it's GimpConfigInterface and check if we get a different pointer. * for it's GimpConfigInterface and check if we get a different
* pointer.
* *
* (if the pointers are the same, param_spec->owner_type's * (if the pointers are the same, param_spec->owner_type's
* GimpConfigInterface is inherited from one of it's parent classes * GimpConfigInterface is inherited from one of it's parent classes
@ -244,11 +246,12 @@ gimp_config_deserialize_property (GimpConfig *config,
{ {
GTypeClass *owner_parent_class; GTypeClass *owner_parent_class;
owner_parent_class = g_type_class_peek_parent (owner_class), owner_parent_class = g_type_class_peek_parent (owner_class);
parent_iface = g_type_interface_peek (owner_parent_class, parent_iface = g_type_interface_peek (owner_parent_class,
GIMP_TYPE_CONFIG); GIMP_TYPE_CONFIG);
} }
}
if (config_iface && if (config_iface &&
config_iface != parent_iface && /* see comment above */ config_iface != parent_iface && /* see comment above */

View File

@ -157,8 +157,7 @@ gimp_config_serialize_property (GimpConfig *config,
GParamSpec *param_spec, GParamSpec *param_spec,
GimpConfigWriter *writer) GimpConfigWriter *writer)
{ {
GTypeClass *owner_class; GimpConfigInterface *config_iface = NULL;
GimpConfigInterface *config_iface;
GimpConfigInterface *parent_iface = NULL; GimpConfigInterface *parent_iface = NULL;
GValue value = { 0, }; GValue value = { 0, };
gboolean success = FALSE; gboolean success = FALSE;
@ -179,7 +178,9 @@ gimp_config_serialize_property (GimpConfig *config,
return TRUE; return TRUE;
} }
owner_class = g_type_class_peek (param_spec->owner_type); if (G_TYPE_IS_OBJECT (param_spec->owner_type))
{
GTypeClass *owner_class = g_type_class_peek (param_spec->owner_type);
config_iface = g_type_interface_peek (owner_class, GIMP_TYPE_CONFIG); config_iface = g_type_interface_peek (owner_class, GIMP_TYPE_CONFIG);
@ -187,7 +188,8 @@ gimp_config_serialize_property (GimpConfig *config,
* which implements it is param_spec->owner_type's class. * which implements it is param_spec->owner_type's class.
* *
* Therefore, we ask param_spec->owner_type's immediate parent class * Therefore, we ask param_spec->owner_type's immediate parent class
* for it's GimpConfigInterface and check if we get a different pointer. * for it's GimpConfigInterface and check if we get a different
* pointer.
* *
* (if the pointers are the same, param_spec->owner_type's * (if the pointers are the same, param_spec->owner_type's
* GimpConfigInterface is inherited from one of it's parent classes * GimpConfigInterface is inherited from one of it's parent classes
@ -197,11 +199,12 @@ gimp_config_serialize_property (GimpConfig *config,
{ {
GTypeClass *owner_parent_class; GTypeClass *owner_parent_class;
owner_parent_class = g_type_class_peek_parent (owner_class), owner_parent_class = g_type_class_peek_parent (owner_class);
parent_iface = g_type_interface_peek (owner_parent_class, parent_iface = g_type_interface_peek (owner_parent_class,
GIMP_TYPE_CONFIG); GIMP_TYPE_CONFIG);
} }
}
if (config_iface && if (config_iface &&
config_iface != parent_iface && /* see comment above */ config_iface != parent_iface && /* see comment above */