Diffusion Krita 4446c5120fb8

Prevent a crash when swap file is not created on OSX

Authored by poke1024 on Oct 2 2017, 7:22 PM.

Description

Prevent a crash when swap file is not created on OSX

Prevents a random crash with Krita 3.2.1 on Mac OS X 10.12.6 (not reproducible).

The swapfile does not get created properly on OS X and thus mmap fails
later on, as there's no file to mmap to.

The reason the swapfile does not get created is that OS X stores each
temp file in its own garbled
path (e.g.

/var/folders/6k/9953vs0513ldszxq8gqjz4mh0000gq/T/KRITA_SWAP_FILE_XXXXXX).

Thus the usual logic implemented in Krita for getting "one"
permanent (i.e. saved in config file) correct tmp path and then creating
a swap file there, is not viable on OS X with OS X's tmp file folder
management.

On OS X, you can get a temp path for a temp file, but when you create
the swap file there later on, the path might already be invalid (this is
also sort of a QT QTemporaryFile problem IMHO, but anyway).

This diff fixes swapfiles on OS X through these changes:

  • Clear all existing configs on OS X that point swapfiles to /var/folders (the internal OS X tmp file archive that must not be stored in a config file, as it is definitely not usually writable or readable across app starts) and make Krita revert to the "default" on such installations Use the home directory on OS X as default swapfile dir, as there is no dedicated tmp file location that allows for setting the swap file name (users can always specify a better swapfile location, but the home dir at least makes it clear where to delete the thing should Krita crash, as opposed to some unnamed large file deep down somewhere in /var/folders/.../.../...).
  • Additionally, this latest diff adds proper error checking on swapfile resizes and swapfile mmap, which should be beneficial for all platforms. Currently if any of these fail, Krita will crash. With these changes, swapping out will just noop gracefully (and print out a warning).

Reviewers: Krita, dkazakov

Reviewed By: Krita, dkazakov

Subscribers: dkazakov, alvinhochun

Differential Revision: https://phabricator.kde.org/D7969

Details

Committed
dkazakovOct 2 2017, 7:25 PM
Reviewer
Krita
Differential Revision
D7969: Prevents crash
Parents
R37:9350250275fd: WinInk: Fix tilt not following device rotation
Branches
Unknown
Tags
Unknown