Android: Fix .kra/.ora corruption on re-saves
Since WriteOnly
mode wasn't handled properly it created weird and nondeterministic bugs which often corrupted the file on resaves or crashed Krita.
Note:
One of the biggest false positive while I was trying to fix this bug was that I couldn't reproduce it on ChromeOS and Android x86_64 (Android 7) emulator. Which made this look like an ARM specific issue. Of course there was none, the older Android implementation truncated the remaining stream when overwritten with a smaller file. So, yes this bug is reproducible on Android 10 x86 implementations as well.
Test Plan
- Create a new file, draw something (preferably on a vector layer) and save it.
- Note the file size in File Manager
- Open the file again and do something to increase the file size and save it.
- Undo what ever was done (i.e decrease the file size).
- Close the file and reopen it.
Before the patch: File should be corrupted in one way or another. Sometimes it would cause crash, sometimes it would open with no layer information.
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.