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.
This commit is contained in:
Michael Natterer 2018-08-20 13:50:31 +02:00
parent 5d937a237b
commit 717c183a3e
1 changed files with 13 additions and 1 deletions

View File

@ -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;
}