From 717c183a3ef7da8db41b768d467f97f77dbab707 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Mon, 20 Aug 2018 13:50:31 +0200 Subject: [PATCH] app: make GimpDeviceInfo more rubust against broken device listings gimp_device_info_set_device(): don't just bail out if a device with the same name is added again, instead, simply continue and overwrite the info's old device with the new one. NOTE that this only happens if something is wrong on the USB or udev or libinput or whatever side and the same device is present multiple times. The only "safe" thing is to assume that devices listed earlier are dead and dangling entities and that the last registered device is the one actually delivering events. --- app/widgets/gimpdeviceinfo.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/widgets/gimpdeviceinfo.c b/app/widgets/gimpdeviceinfo.c index 8e7f812c94..a0adc7ef2e 100644 --- a/app/widgets/gimpdeviceinfo.c +++ b/app/widgets/gimpdeviceinfo.c @@ -617,13 +617,25 @@ gimp_device_info_set_device (GimpDeviceInfo *info, g_printerr ("%s: trying to set GdkDevice '%s' on GimpDeviceInfo " "which already has a device\n", G_STRFUNC, gdk_device_get_name (device)); - return FALSE; + + /* don't bail out here, instead, simply continue and overwrite + * the info's old device with the new one. + * + * NOTE that this only happens if something is wrong on the USB + * or udev or libinput or whatever side and the same device is + * present multiple times. The only "safe" thing is to assume + * that devices listed earlier are dead and dangling entities + * and that the last registered device is the one actually + * delivering events. + */ } else if (! device && ! info->device) { g_printerr ("%s: trying to unset GdkDevice of GimpDeviceInfo '%s'" "which has no device\n", G_STRFUNC, gimp_object_get_name (info)); + + /* bail out, unsetting twice makes no sense */ return FALSE; }