[gthumb] removed calls to g_object_newv
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] removed calls to g_object_newv
- Date: Thu, 10 Jan 2019 18:17:33 +0000 (UTC)
commit 836702d3d3c3ab47c06fda2c24a5baac933523d0
Author: Paolo Bacchilega <paobac src gnome org>
Date: Tue Jan 1 08:33:30 2019 +0100
removed calls to g_object_newv
It's deprecated.
gthumb/dom.c | 6 +++---
gthumb/gth-extensions.c | 2 +-
gthumb/gth-main.c | 54 +++++++++++++++++++++++++++++++++++--------------
3 files changed, 43 insertions(+), 19 deletions(-)
---
diff --git a/gthumb/dom.c b/gthumb/dom.c
index 05bf0f01..526961cc 100644
--- a/gthumb/dom.c
+++ b/gthumb/dom.c
@@ -383,7 +383,7 @@ dom_element_new (const char *a_tag_name)
g_return_val_if_fail (a_tag_name != NULL, NULL);
- self = g_object_newv (DOM_TYPE_ELEMENT, 0, NULL);
+ self = g_object_new (DOM_TYPE_ELEMENT, NULL);
self->tag_name = (a_tag_name == NULL) ? NULL : g_strdup (a_tag_name);
return self;
@@ -605,7 +605,7 @@ dom_text_node_new (const char *a_data)
{
DomTextNode *self;
- self = g_object_newv (DOM_TYPE_TEXT_NODE, 0, NULL);
+ self = g_object_new (DOM_TYPE_TEXT_NODE, NULL);
self->data = (a_data == NULL ? g_strdup ("") : g_strdup (a_data));
return self;
@@ -656,7 +656,7 @@ dom_document_new (void)
{
DomDocument *self;
- self = g_object_newv (DOM_TYPE_DOCUMENT, 0, NULL);
+ self = g_object_new (DOM_TYPE_DOCUMENT, NULL);
return g_object_ref_sink (self);
}
diff --git a/gthumb/gth-extensions.c b/gthumb/gth-extensions.c
index a83b719e..c1eeca3c 100644
--- a/gthumb/gth-extensions.c
+++ b/gthumb/gth-extensions.c
@@ -642,7 +642,7 @@ gth_extension_manager_new (void)
{
GthExtensionManager *manager;
- manager = (GthExtensionManager *) g_object_newv (GTH_TYPE_EXTENSION_MANAGER, 0, NULL);
+ manager = (GthExtensionManager *) g_object_new (GTH_TYPE_EXTENSION_MANAGER, NULL);
gth_extension_manager_load_extensions (manager);
return manager;
diff --git a/gthumb/gth-main.c b/gthumb/gth-main.c
index d3e588ef..a0e86431 100644
--- a/gthumb/gth-main.c
+++ b/gthumb/gth-main.c
@@ -45,9 +45,10 @@ static GMutex register_mutex;
typedef struct {
- GType object_type;
- guint n_params;
- GParameter *params;
+ GType object_type;
+ guint n_params;
+ const char **names;
+ GValue *values;
} GthTypeSpec;
@@ -59,7 +60,8 @@ gth_type_spec_new (GType object_type)
spec = g_new0 (GthTypeSpec, 1);
spec->object_type = object_type;
spec->n_params = 0;
- spec->params = NULL;
+ spec->names = NULL;
+ spec->values = NULL;
return spec;
}
@@ -69,8 +71,9 @@ static void
gth_type_spec_free (GthTypeSpec *spec)
{
while (spec->n_params--)
- g_value_unset (&spec->params[spec->n_params].value);
- g_free (spec->params);
+ g_value_unset (&spec->values[spec->n_params]);
+ g_free (spec->names);
+ g_free (spec->values);
g_free (spec);
}
@@ -81,7 +84,10 @@ gth_type_spec_create_object (GthTypeSpec *spec,
{
GObject *object;
- object = g_object_newv (spec->object_type, spec->n_params, spec->params);
+ object = g_object_new_with_properties (spec->object_type,
+ spec->n_params,
+ spec->names,
+ spec->values);
if (g_object_class_find_property (G_OBJECT_GET_CLASS (object), "id"))
g_object_set (object, "id", object_id, NULL);
@@ -641,7 +647,7 @@ _gth_main_create_type_spec (GType object_type,
GObject *object;
GthTypeSpec *type_spec;
const char *name;
- guint n_alloced_params = 16;
+ guint max_params = 16;
type_spec = gth_type_spec_new (object_type);
@@ -651,8 +657,27 @@ _gth_main_create_type_spec (GType object_type,
GParamSpec *pspec;
char *error = NULL;
- if (type_spec->params == NULL)
- type_spec->params = g_new (GParameter, n_alloced_params);
+ if (type_spec->n_params == max_params - 1) {
+ g_warning ("%s: too many params (max: %d)", G_STRFUNC, max_params);
+ break;
+ }
+
+ if (type_spec->names == NULL) {
+ int i;
+
+ type_spec->names = g_new (const char *, max_params);
+ for (i = 0; i < max_params; i++)
+ type_spec->names[i] = NULL;
+ }
+
+ if (type_spec->values == NULL) {
+ int i;
+
+ type_spec->values = g_new (GValue, max_params);
+ for (i = 0; i < max_params; i++) {
+ type_spec->values[i].g_type = 0;
+ }
+ }
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (object), name);
if (pspec == NULL) {
@@ -662,14 +687,13 @@ _gth_main_create_type_spec (GType object_type,
name);
break;
}
- type_spec->params[type_spec->n_params].name = name;
- type_spec->params[type_spec->n_params].value.g_type = 0;
- g_value_init (&type_spec->params[type_spec->n_params].value, G_PARAM_SPEC_VALUE_TYPE (pspec));
- G_VALUE_COLLECT (&type_spec->params[type_spec->n_params].value, var_args, 0, &error);
+ type_spec->names[type_spec->n_params] = name;
+ g_value_init (&type_spec->values[type_spec->n_params], G_PARAM_SPEC_VALUE_TYPE (pspec));
+ G_VALUE_COLLECT (&type_spec->values[type_spec->n_params], var_args, 0, &error);
if (error != NULL) {
g_warning ("%s: %s", G_STRFUNC, error);
g_free (error);
- g_value_unset (&type_spec->params[type_spec->n_params].value);
+ g_value_unset (&type_spec->values[type_spec->n_params]);
break;
}
type_spec->n_params++;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]