wayland: Fix buffer ref'ing in org_kde_kwin_shadow.commit

In case the current state and the pending state have the same buffer for
a particular side or a corner, that buffer can be prematurely released
because the buffer in the current state is unreferenced first.

The ref/unref order should be vice versa to ensure that the GraphicsBuffer
is not released prematurely.
This commit is contained in:
Vlad Zahorodnii 2024-06-17 13:33:41 +03:00
parent ba599a2aa0
commit 1a7c94b692

View file

@ -139,12 +139,12 @@ void ShadowInterfacePrivate::org_kde_kwin_shadow_commit(Resource *resource)
{
#define BUFFER(__FLAG__, __PART__) \
if (pending.flags & State::Flags::__FLAG__##Buffer) { \
if (current.__PART__) { \
current.__PART__->unref(); \
} \
if (pending.__PART__) { \
pending.__PART__->ref(); \
} \
if (current.__PART__) { \
current.__PART__->unref(); \
} \
current.__PART__ = pending.__PART__; \
}
BUFFER(Left, left)