[gimp] libgimpconfig: this is the appropriate fix for the previous assert.



commit e6350f94594f46460e2df48ec4c4738f966dadfb
Author: Jehan <jehan girinstud io>
Date:   Thu Feb 10 22:09:43 2022 +0100

    libgimpconfig: this is the appropriate fix for the previous assert.
    
    Since the parsing failure I was experiencing was normal (not a bug), and
    since I was not seeing error being passed down to deserialize(), I
    assume this assert was always wrong. I hadn't realize that the GError
    object was in fact populated by deserialized through g_scanner_error()
    calls which were setting the GError passed at creation of the scanner
    through a handler.
    
    So there was indeed a bug in one of the functions called by our
    deserialize() implementation. There was one failure case where the error
    was just reported with g_warning() instead of g_scanner_error().
    
    Now that it's fixed, I brought back the asserts (previous commits)
    because the error object is actually always well populated.

 libgimpconfig/gimpconfig-deserialize.c | 5 +++--
 libgimpconfig/gimpconfig-iface.c       | 5 +++++
 2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/libgimpconfig/gimpconfig-deserialize.c b/libgimpconfig/gimpconfig-deserialize.c
index d9d22fa403..728d856132 100644
--- a/libgimpconfig/gimpconfig-deserialize.c
+++ b/libgimpconfig/gimpconfig-deserialize.c
@@ -1009,8 +1009,9 @@ gimp_config_deserialize_any (GValue     *value,
 
   if (!g_value_type_transformable (G_TYPE_STRING, prop_spec->value_type))
     {
-      g_warning ("%s: %s can not be transformed from a string",
-                 G_STRFUNC, g_type_name (prop_spec->value_type));
+      g_scanner_error (scanner,
+                       "%s can not be transformed from a string",
+                       g_type_name (prop_spec->value_type));
       return G_TOKEN_NONE;
     }
 
diff --git a/libgimpconfig/gimpconfig-iface.c b/libgimpconfig/gimpconfig-iface.c
index 51d5c97b56..33847fe6eb 100644
--- a/libgimpconfig/gimpconfig-iface.c
+++ b/libgimpconfig/gimpconfig-iface.c
@@ -495,6 +495,11 @@ gimp_config_deserialize_file (GimpConfig  *config,
   gimp_scanner_unref (scanner);
 
   if (! success)
+    /* If we get this assert, it means we have a bug in one of the
+     * deserialize() implementations. Any failure case should report the
+     * error condition with g_scanner_error() which will populate the
+     * error object passed in gimp_scanner_new*().
+     */
     g_assert (error == NULL || *error != NULL);
 
   return success;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]