Skip to content

WIP Fix xcf library closing Krita suddenly

Agata Cacko requested to merge tiar/xcf_import_error_handling into master

Before this patch, xcf library that Krita uses to open xcf files would close Krita unexpectedly in case of a broken xcf file. This patch fixes this problem and provides a basic error handling for xcf library.

There is a bit of a problem with leaking memory - I didn't check it with valgrind yet, but it would be beneficial to make a test with broken files and check it... The library was written under the assumption that in case of any error it can just close, while in our case we want it to release all the memory and return an error code. I tried to patch is as well as I could, but I didn't check all the code or how the memory is managed. Boud said that it's ok. (Well, one can consider it better than just closing Krita. Also I'm not sure if xcf library freed memory on exit anyway... So we leave it to kernel to take care of it anyway - after my patch, user can at least save their work before kernel cleans after Krita ;) ).

Test Plan

  • Run xcf tests (they should pass just as before).
  • Rename an empty file to file.xcf and try to open (before: Krita closes; now: Krita says that it can't open the file).
  • Check broken xcf files with valgrind (I need test cases though... I have no broken files yet).

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken.
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.

Merge request reports