Skip to content

Checking success of a GEGL graph processing

Jehan requested to merge wip/Jehan/gegl_node_process_success into master

Currently if we run a GEGL processing (with gegl_node_process(), gegl_node_blit(), a GeglProcessor, etc.), we just have to assume everything went fine. Actually the process() virtual method of GeglOperation returns a boolean, but GEGL core does not actually care or even check the returned value.

That's quite annoying as real life occurs, and you can get a bunch of unexpected issue, out of your reach (because of system issues, or because it requires external source/input, etc.). For instance, a sink operation may try to write on a file without permission, or a source operation may try to read a corrupted file, and so on.

For context, I got annoyed by this when I saved a .mov file compressed with MP4 and it turns out that MP4 (or libx264 implementation) does not accept odd dimension file. But there was no way to know the error unless I ran the application through a terminal where ffmpeg was outputting the error on stderr. Of course, best case is to know this and implement this limitation in the GUI, but there are always unexpected surprises in third-party libraries.

So my proposition is to add 2 new functions to the public API (first commit):

  • gegl_node_process_success() can be run after processing a GEGL graph (through gegl_node_process(), gegl_node_blit(), gegl_node_blit_buffer() or with gegl_processor_work()). It will tell if the processing succeeded, and can optionally return a GError.

  • gegl_operation_set_error() is to be used by operations when they fail to describe the error which happened. If an operation fails without setting an error this way, gegl_node_process_success() will return a generic error.

Then I improved gegl:png-save and gegl:png-load by using gegl_operation_set_error() appropriately. I also did the same for gegl:ff-save of course so that it actually propagates the error to GEGL (hence to whatever calling application for proper handling).

And finally I added a unit test with a few simple cases: loading invalid files, loading non-readable file, saving in a non-writable file and finally saving a MP4 with odd dimensions.

Merge request reports