Prevents a random crash with Krita 3.2.1 on Mac OS X 10.12.6 (not reproducible).
The crash happened in memcpy in KisSwappedDataStore::swapOutTileData; see attach crash log:
Since the crash is a clean null pointer memory fault, and since m_buffer.data() is highly unlikely to be null and it's allocated a few lines before using m_buffer.resize(), I highly suspect ptr, i.e. m_swapSpace->getWriteChunkPtr(chunk) to be the culprit here.
The only case I can imagine this goes wrong, if m_file.map in KisMemoryWindow::adjustWindow yields null; indeed the QT docs say that QTemporaryFile::map may return 0 here (http://doc.qt.io/qt-5/qfiledevice.html#map).
A better fix than this PR would actually deal properly with the situation of not being able to swap out or swap in tiles (without having to abort the program). Two ideas for this:
(1) half the chunk size in KisMemoryWindow::adjustWindow until map succeeds?
(2) make KisTileDataStore::trySwapTileData just fail silently? (But what to do with swap ins?)