[gimp/gimp-2-10] app: make GimpDeviceInfo more rubust against broken device listings



commit 7d9f79427fa821e10cc236ff72a65ff914fc0b87
Author: Michael Natterer <mitch gimp org>
Date:   Mon Aug 20 13:50:31 2018 +0200

    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.
    
    (cherry picked from commit 717c183a3ef7da8db41b768d467f97f77dbab707)

 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 eba9a8b899..dea7a1a2d4 100644
--- a/app/widgets/gimpdeviceinfo.c
+++ b/app/widgets/gimpdeviceinfo.c
@@ -517,13 +517,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;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]