Fix crash in WaylandGestures during global Wayland teardown
Description
This PR fixes a segmentation fault in Gwenview that occurs on Wayland when the zwp_pointer_gestures_v1 global object is removed (e.g., during compositor shutdown or when an input device is disconnected).
Previously, when the Wayland pointer gesture global was removed, PointerGestures::activeChanged was emitted and WaylandGestures::init() was unconditionally called. Inside init(), we attempt to fetch the native wl_pointer, which crashes inside QtWayland (QWaylandInputDevice::pointer) because the default input device has already been torn down and the pointer is null.
Changes Made
- Check
m_pointerGestures->isActive()before re-initializing gestures inside theactiveChangedslot. - Safely destroy and delete the existing
m_pinchGesturewhen the extension becomes inactive, preventing lingering and invalid Wayland objects. - Initialize
m_pinchGesturetonullptrin the constructor to avoid the destruction of an uninitialized pointer. - Added a safety guard in
init()to properly destroy and overwrite the previousm_pinchGestureif re-initialization occurs.
Bug Reference
Fixes Red Hat Bugzilla: #2480139