Don't release client buffer after compositor tear-down
Client buffers are shared between the main and render threads.
They are reference counted and will be deleted when the last
reference is dropped. One of the references is a texture
provider on the render thread.
An error could occur in the case where the window that owns
the scenegraph is not a descendant of the compositor. Since
the texture provider is deferred-deleted when the compositor
is destroyed, the actual deletion will come later, and
potentially after the compositor has destroyed the wl_display.
In this case, we cannot send any events on the display.
This does not happen in the case of our compositor examples,
since the window will be a child of the WaylandOutput, so the
compositor will not destroy the display before the scenegraph
has been torn down as well.
To avoid this crash, we report the fact that the compositor has
been deleted to the client buffers. When they are later deleted,
they will see this and skip sending the release.
Note that the compositor should ideally close the clients
gracefully before being destroyed, but it should also not crash
when failing to do so.
To minimize the impact for the normal use case, we do this with
a simple atomic int. Since the deferred delete of the texture
provider always happens when the render thread is blocked, we
can get away without additional locks, as we know the compositor
destructor will never be simultaenous with the client buffer
destructor.
Fixes: QTBUG-144115
Change-Id: I52fe346d4b59b1f698a02b619cd844215c3d8e19
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>