[gimp] libgimp, libgimpconfig: gimp_config_deserialize_file() should not…



commit 73c0ee8da7abd66b7d84fff8d585f875e359e2ed
Author: Jehan <jehan girinstud io>
Date:   Thu Feb 10 17:46:55 2022 +0100

    libgimp, libgimpconfig: gimp_config_deserialize_file() should not…
    
    … assert the existence of GError.
    
    This is even worse as deserialize() method does not even take a GError
    parameter anyway so this assert will always go off when a
    deserialization failed (which happened in my case as I was working on a
    plug-in API, hence gimp_procedure_config_load_last() actually failed to
    load a previous version of the plug-in-settings when I changed a
    procedure arg's type).
    
    Just fail the deserialization normally and let the calling code handling
    this case. Nevertheless it is kind of useful to bubble-up the error to
    calling code, so I add a TODO in the interface header (hopefully to see
    and improve this before we release GIMP 3.0).

 libgimp/gimpprocedureconfig.c    | 3 ++-
 libgimpconfig/gimpconfig-iface.c | 3 ---
 libgimpconfig/gimpconfig-iface.h | 3 +++
 3 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/libgimp/gimpprocedureconfig.c b/libgimp/gimpprocedureconfig.c
index 3dbd8cbea8..71544cf5dd 100644
--- a/libgimp/gimpprocedureconfig.c
+++ b/libgimp/gimpprocedureconfig.c
@@ -981,7 +981,8 @@ gimp_procedure_config_load_last (GimpProcedureConfig  *config,
                                           file,
                                           NULL, error);
 
-  if (! success && (*error)->code == GIMP_CONFIG_ERROR_OPEN_ENOENT)
+  if (! success && error && *error &&
+      (*error)->code == GIMP_CONFIG_ERROR_OPEN_ENOENT)
     {
       g_clear_error (error);
     }
diff --git a/libgimpconfig/gimpconfig-iface.c b/libgimpconfig/gimpconfig-iface.c
index 51d5c97b56..65e83c4eca 100644
--- a/libgimpconfig/gimpconfig-iface.c
+++ b/libgimpconfig/gimpconfig-iface.c
@@ -494,9 +494,6 @@ gimp_config_deserialize_file (GimpConfig  *config,
 
   gimp_scanner_unref (scanner);
 
-  if (! success)
-    g_assert (error == NULL || *error != NULL);
-
   return success;
 }
 
diff --git a/libgimpconfig/gimpconfig-iface.h b/libgimpconfig/gimpconfig-iface.h
index 605e999a1a..ac3ad83b0f 100644
--- a/libgimpconfig/gimpconfig-iface.h
+++ b/libgimpconfig/gimpconfig-iface.h
@@ -40,6 +40,9 @@ struct _GimpConfigInterface
   gboolean     (* serialize)            (GimpConfig       *config,
                                          GimpConfigWriter *writer,
                                          gpointer          data);
+  /* TODO: we should add a GError** parameter to the deserialize()
+   * method in order to be able to report errors.
+   */
   gboolean     (* deserialize)          (GimpConfig       *config,
                                          GScanner         *scanner,
                                          gint              nest_level,


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