[libgit2-glib] ggit_object_factory: Replace use of deprecated g_object_newv
- From: Alberto Fanjul <albfan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgit2-glib] ggit_object_factory: Replace use of deprecated g_object_newv
- Date: Mon, 2 Mar 2020 08:57:14 +0000 (UTC)
commit 67a191a6bd4c4f6bb45f73ca28496e283128b826
Author: Jan Alexander Steffens (heftig) <jan steffens gmail com>
Date: Sun Mar 1 17:31:10 2020 +0000
ggit_object_factory: Replace use of deprecated g_object_newv
GParameter is likewise deprecated and provokes warnings.
libgit2-glib/ggit-object-factory.c | 49 +++++++++++++++++---------------------
1 file changed, 22 insertions(+), 27 deletions(-)
---
diff --git a/libgit2-glib/ggit-object-factory.c b/libgit2-glib/ggit-object-factory.c
index efc3601..5b032cf 100644
--- a/libgit2-glib/ggit-object-factory.c
+++ b/libgit2-glib/ggit-object-factory.c
@@ -185,26 +185,6 @@ ggit_object_factory_unregister (GgitObjectFactory *factory,
}
}
-static GParameter *
-convert_to_gparameter (GObjectConstructParam *params,
- guint num)
-{
- GParameter *ret;
- guint i;
-
- ret = g_new0 (GParameter, num);
-
- for (i = 0; i < num; ++i)
- {
- ret[i].name = params[i].pspec->name;
-
- g_value_init (&ret[i].value, G_VALUE_TYPE (params[i].value));
- g_value_copy (params[i].value, &ret[i].value);
- }
-
- return ret;
-}
-
/**
* ggit_object_factory_construct:
* @factory: a #GgitObjectFactory.
@@ -235,21 +215,36 @@ ggit_object_factory_construct (GgitObjectFactory *factory,
if (val)
{
- /* convert construct properties to gparameter and call newv */
- GParameter *params;
+ /* convert construct properties and call new_with_properties */
+ const char **names;
+ GValue *values;
guint i;
- params = convert_to_gparameter (construct_properties,
- n_construct_properties);
+ names = g_new (const char *, n_construct_properties);
+ values = g_new0 (GValue, n_construct_properties);
+
+ for (i = 0; i < n_construct_properties; ++i)
+ {
+ const GValue *value;
+
+ names[i] = construct_properties[i].pspec->name;
+ value = construct_properties[i].value;
+
+ g_value_init (&values[i], G_VALUE_TYPE (value));
+ g_value_copy (value, &values[i]);
+ }
- ret = g_object_newv (val->type, n_construct_properties, params);
+ ret = g_object_new_with_properties (val->type,
+ n_construct_properties,
+ names, values);
for (i = 0; i < n_construct_properties; ++i)
{
- g_value_unset (¶ms[i].value);
+ g_value_unset (&values[i]);
}
- g_free (params);
+ g_free (names);
+ g_free (values);
}
else
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]