My KWIN fork where I work on features like per-output virtual desktops
Find a file
Martin Gräßlin c81271a3b4 Fix shared memory access in BufferInterface
The BufferInterface used nested calls of wl_shm_buffer_begin_access
and allowed multiple different BufferInterfaces to be in a block
between wl_shm_buffer_begin_access and wl_shm_buffer_end_access.
But this is not allowed: nesting is only possible if it accesses
the same buffer!

This resulted in an abort when we accessed two BufferInterfaces
at the same time. The added test case aborts in the previous
version.

The fix now changes the semantic of the method. The BufferInterface
doesn't hold the QImage any more, but creates a new one every time
::data is invoked. The QImage is created with a custom cleanup
function which calls to wl_shm_buffer_end_access. It ensures that
we don't call into wl_shm_buffer_begin_access as long as there is
a valid QImage for any other BufferInterface still around and
instead returns a null QImage.

Thus a user of a BufferInterface::data should destroy the returned
QImage as soon as it's no longer needed or create a deep copy if
it needs to be kept around.
2014-11-13 08:30:51 +01:00
src/wayland Fix shared memory access in BufferInterface 2014-11-13 08:30:51 +01:00