mirror of https://github.com/GNOME/gimp.git
Fixed handling of G_PARAM_CONSTRUCT_ONLY properties:
2003-09-29 Michael Natterer <mitch@gimp.org> Fixed handling of G_PARAM_CONSTRUCT_ONLY properties: * app/config/gimpconfig.c (gimp_config_iface_duplicate): build a GParameter array of G_PARAM_CONSTRUCT_ONLY properties and use g_object_newv() instead of g_object_new() to create the copy. * app/config/gimpconfig-utils.c (gimp_config_copy_properties) (gimp_consif_reset_properties): don't try to copy/reset G_PARAM_CONSTRUCT_ONLY properties because it is impossible. (gimp_config_connect_notify): ditto. Also don't try to read from unreadable or write to unwritable properties.
This commit is contained in:
parent
2b57062c01
commit
017d183968
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
|||
2003-09-29 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
Fixed handling of G_PARAM_CONSTRUCT_ONLY properties:
|
||||
|
||||
* app/config/gimpconfig.c (gimp_config_iface_duplicate): build
|
||||
a GParameter array of G_PARAM_CONSTRUCT_ONLY properties and
|
||||
use g_object_newv() instead of g_object_new() to create the
|
||||
copy.
|
||||
|
||||
* app/config/gimpconfig-utils.c
|
||||
(gimp_config_copy_properties)
|
||||
(gimp_consif_reset_properties): don't try to copy/reset
|
||||
G_PARAM_CONSTRUCT_ONLY properties because it is impossible.
|
||||
|
||||
(gimp_config_connect_notify): ditto. Also don't try to read
|
||||
from unreadable or write to unwritable properties.
|
||||
|
||||
2003-09-29 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/tools/gimpcroptool.c: minor cleanups.
|
||||
|
|
|
@ -95,14 +95,19 @@ gimp_config_connect_notify (GObject *src,
|
|||
GParamSpec *param_spec,
|
||||
GObject *dest)
|
||||
{
|
||||
GValue value = { 0, };
|
||||
if ((param_spec->flags & G_PARAM_READABLE) &&
|
||||
(param_spec->flags & G_PARAM_WRITABLE) &&
|
||||
! (param_spec->flags & G_PARAM_CONSTRUCT_ONLY))
|
||||
{
|
||||
GValue value = { 0, };
|
||||
|
||||
g_value_init (&value, param_spec->value_type);
|
||||
g_value_init (&value, param_spec->value_type);
|
||||
|
||||
g_object_get_property (src, param_spec->name, &value);
|
||||
g_object_set_property (dest, param_spec->name, &value);
|
||||
g_object_get_property (src, param_spec->name, &value);
|
||||
g_object_set_property (dest, param_spec->name, &value);
|
||||
|
||||
g_value_unset (&value);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -182,8 +187,9 @@ gimp_config_copy_properties (GObject *src,
|
|||
|
||||
prop_spec = property_specs[i];
|
||||
|
||||
if (prop_spec->flags & G_PARAM_READABLE &&
|
||||
prop_spec->flags & G_PARAM_WRITABLE)
|
||||
if ((prop_spec->flags & G_PARAM_READABLE) &&
|
||||
(prop_spec->flags & G_PARAM_WRITABLE) &&
|
||||
! (prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
|
||||
{
|
||||
if (G_IS_PARAM_SPEC_OBJECT (prop_spec) &&
|
||||
(prop_spec->flags & GIMP_PARAM_AGGREGATE))
|
||||
|
@ -264,7 +270,8 @@ gimp_config_reset_properties (GObject *object)
|
|||
|
||||
prop_spec = property_specs[i];
|
||||
|
||||
if (prop_spec->flags & G_PARAM_WRITABLE)
|
||||
if ((prop_spec->flags & G_PARAM_WRITABLE) &&
|
||||
! (prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
|
||||
{
|
||||
if (G_IS_PARAM_SPEC_OBJECT (prop_spec))
|
||||
{
|
||||
|
|
|
@ -116,7 +116,49 @@ gimp_config_iface_deserialize (GObject *object,
|
|||
static GObject *
|
||||
gimp_config_iface_duplicate (GObject *object)
|
||||
{
|
||||
GObject *dup = g_object_new (G_TYPE_FROM_INSTANCE (object), NULL);
|
||||
GObjectClass *klass;
|
||||
GParamSpec **property_specs;
|
||||
guint n_property_specs;
|
||||
GParameter *construct_params = NULL;
|
||||
gint n_construct_params = 0;
|
||||
guint i;
|
||||
GObject *dup;
|
||||
|
||||
klass = G_OBJECT_GET_CLASS (object);
|
||||
|
||||
property_specs = g_object_class_list_properties (klass, &n_property_specs);
|
||||
|
||||
construct_params = g_new0 (GParameter, n_property_specs);
|
||||
|
||||
for (i = 0; i < n_property_specs; i++)
|
||||
{
|
||||
GParamSpec *prop_spec = property_specs[i];
|
||||
|
||||
if ((prop_spec->flags & G_PARAM_READABLE) &&
|
||||
(prop_spec->flags & G_PARAM_WRITABLE) &&
|
||||
(prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
|
||||
{
|
||||
GParameter *construct_param;
|
||||
|
||||
construct_param = &construct_params[n_construct_params++];
|
||||
|
||||
construct_params->name = prop_spec->name;
|
||||
|
||||
g_value_init (&construct_params->value, prop_spec->value_type);
|
||||
g_object_get_property (object, prop_spec->name,
|
||||
&construct_param->value);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (property_specs);
|
||||
|
||||
dup = g_object_newv (G_TYPE_FROM_INSTANCE (object),
|
||||
n_construct_params, construct_params);
|
||||
|
||||
for (i = 0; i < n_construct_params; i++)
|
||||
g_value_unset (&construct_params[i].value);
|
||||
|
||||
g_free (construct_params);
|
||||
|
||||
gimp_config_copy_properties (object, dup);
|
||||
|
||||
|
|
|
@ -116,7 +116,49 @@ gimp_config_iface_deserialize (GObject *object,
|
|||
static GObject *
|
||||
gimp_config_iface_duplicate (GObject *object)
|
||||
{
|
||||
GObject *dup = g_object_new (G_TYPE_FROM_INSTANCE (object), NULL);
|
||||
GObjectClass *klass;
|
||||
GParamSpec **property_specs;
|
||||
guint n_property_specs;
|
||||
GParameter *construct_params = NULL;
|
||||
gint n_construct_params = 0;
|
||||
guint i;
|
||||
GObject *dup;
|
||||
|
||||
klass = G_OBJECT_GET_CLASS (object);
|
||||
|
||||
property_specs = g_object_class_list_properties (klass, &n_property_specs);
|
||||
|
||||
construct_params = g_new0 (GParameter, n_property_specs);
|
||||
|
||||
for (i = 0; i < n_property_specs; i++)
|
||||
{
|
||||
GParamSpec *prop_spec = property_specs[i];
|
||||
|
||||
if ((prop_spec->flags & G_PARAM_READABLE) &&
|
||||
(prop_spec->flags & G_PARAM_WRITABLE) &&
|
||||
(prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
|
||||
{
|
||||
GParameter *construct_param;
|
||||
|
||||
construct_param = &construct_params[n_construct_params++];
|
||||
|
||||
construct_params->name = prop_spec->name;
|
||||
|
||||
g_value_init (&construct_params->value, prop_spec->value_type);
|
||||
g_object_get_property (object, prop_spec->name,
|
||||
&construct_param->value);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (property_specs);
|
||||
|
||||
dup = g_object_newv (G_TYPE_FROM_INSTANCE (object),
|
||||
n_construct_params, construct_params);
|
||||
|
||||
for (i = 0; i < n_construct_params; i++)
|
||||
g_value_unset (&construct_params[i].value);
|
||||
|
||||
g_free (construct_params);
|
||||
|
||||
gimp_config_copy_properties (object, dup);
|
||||
|
||||
|
|
|
@ -95,14 +95,19 @@ gimp_config_connect_notify (GObject *src,
|
|||
GParamSpec *param_spec,
|
||||
GObject *dest)
|
||||
{
|
||||
GValue value = { 0, };
|
||||
if ((param_spec->flags & G_PARAM_READABLE) &&
|
||||
(param_spec->flags & G_PARAM_WRITABLE) &&
|
||||
! (param_spec->flags & G_PARAM_CONSTRUCT_ONLY))
|
||||
{
|
||||
GValue value = { 0, };
|
||||
|
||||
g_value_init (&value, param_spec->value_type);
|
||||
g_value_init (&value, param_spec->value_type);
|
||||
|
||||
g_object_get_property (src, param_spec->name, &value);
|
||||
g_object_set_property (dest, param_spec->name, &value);
|
||||
g_object_get_property (src, param_spec->name, &value);
|
||||
g_object_set_property (dest, param_spec->name, &value);
|
||||
|
||||
g_value_unset (&value);
|
||||
g_value_unset (&value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -182,8 +187,9 @@ gimp_config_copy_properties (GObject *src,
|
|||
|
||||
prop_spec = property_specs[i];
|
||||
|
||||
if (prop_spec->flags & G_PARAM_READABLE &&
|
||||
prop_spec->flags & G_PARAM_WRITABLE)
|
||||
if ((prop_spec->flags & G_PARAM_READABLE) &&
|
||||
(prop_spec->flags & G_PARAM_WRITABLE) &&
|
||||
! (prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
|
||||
{
|
||||
if (G_IS_PARAM_SPEC_OBJECT (prop_spec) &&
|
||||
(prop_spec->flags & GIMP_PARAM_AGGREGATE))
|
||||
|
@ -264,7 +270,8 @@ gimp_config_reset_properties (GObject *object)
|
|||
|
||||
prop_spec = property_specs[i];
|
||||
|
||||
if (prop_spec->flags & G_PARAM_WRITABLE)
|
||||
if ((prop_spec->flags & G_PARAM_WRITABLE) &&
|
||||
! (prop_spec->flags & G_PARAM_CONSTRUCT_ONLY))
|
||||
{
|
||||
if (G_IS_PARAM_SPEC_OBJECT (prop_spec))
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue