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).
This commit is contained in:
Jehan 2022-02-10 17:46:55 +01:00
parent ef3549648f
commit 73c0ee8da7
3 changed files with 5 additions and 4 deletions

View File

@ -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);
}

View File

@ -494,9 +494,6 @@ gimp_config_deserialize_file (GimpConfig *config,
gimp_scanner_unref (scanner);
if (! success)
g_assert (error == NULL || *error != NULL);
return success;
}

View File

@ -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,