Skip to content

Remove resource file after import if it cannot be loaded

Before this commit, if the user tried to import a resource file that is incorrect (cannot be loaded for any reason), Krita would still leave the incorrect file in the resource folder. While it could potentially have some uses (for example the user is importing a resource file that works with a different version of Krita, or with different plugins), usually it's unneeded and the file imported is indeed in incorrect file format etc.

This commit ensures that if the freshly imported resource file cannot be loaded, it is removed.

BUG:446279

https://bugs.kde.org/show_bug.cgi?id=446279

Test Plan

  1. Create a file called pattern.png~ (can be an image file or not)
  2. Import it before my MR.
  3. See that it's in the /patterns/ folder despite Krita saying that the import failed (because Krita can't read that file)
  4. Remove that file
  5. Switch to the MR version
  6. Import the file
  7. See that it's nowhere to be seen in /patterns/

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. (If not possible, don't hesitate to ask for help!)
  • 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.
Edited by Agata Cacko

Merge request reports