Alternative gexiv2_metadata_get_tag_multiple() and gexiv2_metadata_set_tag_multiple() with a GError
In GIMP, we sometimes have these WARNINGs on calls for some metadata (here for instance XMP pmi):
No namespace info available for XMP prefix `pmi'
Traces indicate these are produced by (at least) gexiv2_metadata_get_tag_multiple()
and gexiv2_metadata_set_tag_multiple()
. I could see that the error actually comes from Exiv2 and from what I see, when Exiv2 just raises some error, you catch it and make a WARNING of it (e.g. in gexiv2_metadata_get_xmp_tag_multiple()
:
} catch (Exiv2::Error& e) {
LOG_ERROR(e);
}
Which basically just raises a g_warning()
.
I haven't really looked how it works, but I am guessing that this just means that Exiv2 doesn't handle the contents for this metadata (apparently an application can register new metadata namespaces for supporting for types of data?), which is fine (I don't assume Exiv2 knows all possible metadata). In any case, since there can be technically an infinity of metadata, Exiv2 will never support all metadata, so such warnings would always be outputted at some point, which is not right. Warnings and criticals should be outputted for actual bugs or problems, not for things the library has no control on.
Could there be an alternate version for these functions which would just set a GError instead (if set, or just do nothing if one set NULL for the error parameter, as sometimes, you may not care and just want to ignore):
gchar** gexiv2_metadata_try_get_xmp_tag_multiple (GExiv2Metadata *self, const gchar* tag, GError **error);
gboolean gexiv2_metadata_try_set_xmp_tag_multiple (GExiv2Metadata *self, const gchar* tag, const gchar** values, GError **error);
Or whatever other name (just an example, I'm not the best at naming!).
Basically don't output warnings, but set a GError which calling application can actually do something about (which may be ignore it, print to stderr, raise a popup with the error, etc. or even actually make a WARNING of it, whatever the application chooses). Of course GLib warnings/errors can actually be caught, but this is a complicated handler system which an application should not be expected to set up for calling just one function (imagine if we had to set new warning handlers before every dependency functions, then unset it after… hell in code!). We actually do set generic handlers for the whole application, which run a debugger when warnings or critical appears as these are supposed to be bugs we want to investigate (that also means it freezes the GUI for a few secs). This is how I discovered the issue. So my advice would even be to do the new functions and keep the old ones for compatibility (of course), but deprecate them in favor of GError versions.
Thanks!
See also gimp#5863 (closed).