From ccde23ebaa628d7536bee6b27588d9fecd1aa753 Mon Sep 17 00:00:00 2001 From: Jehan Date: Tue, 18 Jul 2023 16:29:47 +0200 Subject: [PATCH] =?UTF-8?q?libgimpconfig:=20don't=20break=20serializing=20?= =?UTF-8?q?properties=20if=20one=20property=20serialization=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … fails. This happens for plug-in settings storage. Serialization stops at first failed property serialization, whereas we could store more. This feels like the last settings feature is broken. --- libgimpconfig/gimpconfig-serialize.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/libgimpconfig/gimpconfig-serialize.c b/libgimpconfig/gimpconfig-serialize.c index d1d79d2170..e5d21d6c70 100644 --- a/libgimpconfig/gimpconfig-serialize.c +++ b/libgimpconfig/gimpconfig-serialize.c @@ -73,6 +73,7 @@ gimp_config_serialize_properties (GimpConfig *config, GParamSpec **property_specs; guint n_property_specs; guint i; + gboolean success = TRUE; g_return_val_if_fail (G_IS_OBJECT (config), FALSE); @@ -81,7 +82,7 @@ gimp_config_serialize_properties (GimpConfig *config, property_specs = g_object_class_list_properties (klass, &n_property_specs); if (! property_specs) - return TRUE; + return success; for (i = 0; i < n_property_specs; i++) { @@ -90,13 +91,16 @@ gimp_config_serialize_properties (GimpConfig *config, if (! (prop_spec->flags & GIMP_CONFIG_PARAM_SERIALIZE)) continue; + /* Some properties may fail writing, which shouldn't break serializing + * more properties, yet final result would be a (partial) failure. + */ if (! gimp_config_serialize_property (config, prop_spec, writer)) - return FALSE; + success = FALSE; } g_free (property_specs); - return TRUE; + return success; } /** @@ -119,7 +123,8 @@ gimp_config_serialize_changed_properties (GimpConfig *config, GParamSpec **property_specs; guint n_property_specs; guint i; - GValue value = G_VALUE_INIT; + GValue value = G_VALUE_INIT; + gboolean success = TRUE; g_return_val_if_fail (G_IS_OBJECT (config), FALSE); @@ -128,7 +133,7 @@ gimp_config_serialize_changed_properties (GimpConfig *config, property_specs = g_object_class_list_properties (klass, &n_property_specs); if (! property_specs) - return TRUE; + return success; for (i = 0; i < n_property_specs; i++) { @@ -142,8 +147,11 @@ gimp_config_serialize_changed_properties (GimpConfig *config, if (! g_param_value_defaults (prop_spec, &value)) { + /* Some properties may fail writing, which shouldn't break serializing + * more properties, yet final result would be a (partial) failure. + */ if (! gimp_config_serialize_property (config, prop_spec, writer)) - return FALSE; + success = FALSE; } g_value_unset (&value); @@ -151,7 +159,7 @@ gimp_config_serialize_changed_properties (GimpConfig *config, g_free (property_specs); - return TRUE; + return success; } /**