[json-glib: 1/2] serializable: Fix default deserialization method.
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [json-glib: 1/2] serializable: Fix default deserialization method.
- Date: Tue, 14 Jan 2020 11:29:29 +0000 (UTC)
commit c6cab478f22d2e47c41fe0f1fef7f0eaf4a5d869
Author: Jeremy Philippe <jeremy philippe gmail com>
Date: Fri Aug 23 01:16:00 2019 +0200
serializable: Fix default deserialization method.
json_serializable_default_deserialize_property() fails when called
with an uninitialized value.
This violates the API since value is marked as an out parameter.
Fixes https://gitlab.gnome.org/GNOME/json-glib/issues/39
json-glib/json-serializable.c | 9 +++++++++
1 file changed, 9 insertions(+)
---
diff --git a/json-glib/json-serializable.c b/json-glib/json-serializable.c
index eb7556d..8eb64d7 100644
--- a/json-glib/json-serializable.c
+++ b/json-glib/json-serializable.c
@@ -77,6 +77,11 @@ json_serializable_serialize_property (JsonSerializable *serializable,
* Asks a #JsonSerializable implementation to deserialize the
* property contained inside @property_node into @value.
*
+ * The @value can be:
+ * - an empty #GValue initialized by %G_VALUE_INIT, which will be automatically
+ * initialized with the expected type of the property (since JSON-GLib 1.6)
+ * - a #GValue initialized with the expected type of the property
+ *
* Return value: %TRUE if the property was successfully deserialized.
*/
gboolean
@@ -111,6 +116,10 @@ json_serializable_real_deserialize (JsonSerializable *serializable,
JsonNode *node)
{
JSON_NOTE (GOBJECT, "Default deserialization for property '%s'", pspec->name);
+
+ if (!G_IS_VALUE (value))
+ g_value_init (value, G_PARAM_SPEC_VALUE_TYPE (pspec));
+
return json_deserialize_pspec (value, pspec, node);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]