Don't process pad button events from a device that has been removed

This fixes a rare crash where we may dereference a null
TabletV2Interface in findAndAdoptPad. This can happen because the
underlying device disappears, and we call
libinput_device_group_set_user_data (what tabletPadId.data points to)
to reset the user data to null.

Similar to what we do to tablet tool events (see tabletToolEvent), we
should check if this is null before continuing.

Fixes KWIN-3R6
This commit is contained in:
Joshua Goins 2024-08-07 16:49:11 -04:00
parent 087b2c290f
commit 9f6c969aba

View file

@ -2399,7 +2399,13 @@ public:
return nullptr; return nullptr;
} }
// NOTE: tablet may be nullptr when the device is removed (see ::removeDevice) but events from the tool
// may still happen.
auto tablet = static_cast<TabletV2Interface *>(tabletPadId.data); auto tablet = static_cast<TabletV2Interface *>(tabletPadId.data);
if (!tablet) {
return nullptr;
}
SurfaceInterface *surface = window->surface(); SurfaceInterface *surface = window->surface();
auto pad = tablet->pad(); auto pad = tablet->pad();
if (!pad) { if (!pad) {