[gnome-settings-daemon/gnome-3-20] wacom: Fix hot(un)plug related crashes



commit 7140b24b4ec2d2271035a69ee767dc32a27dab3d
Author: Jason Gerecke <killertofu gmail com>
Date:   Wed Jul 6 16:07:17 2016 -0700

    wacom: Fix hot(un)plug related crashes
    
    Most of the wacom plugin code protects X11 calls with gdk_error_trap_push/pop
    and prints a warning if something fails. There were two calls that were not
    protected, however, and one use of g_error instead of g_warning that would
    cause the g-s-d process to die if e.g. the tablet disappears while g-s-d is
    trying to work on it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=765996

 plugins/common/gsd-input-helper.c |    5 +++++
 plugins/wacom/gsd-wacom-device.c  |    5 ++++-
 plugins/wacom/gsd-wacom-manager.c |    4 ++--
 3 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/plugins/common/gsd-input-helper.c b/plugins/common/gsd-input-helper.c
index 077ff1c..4100599 100644
--- a/plugins/common/gsd-input-helper.c
+++ b/plugins/common/gsd-input-helper.c
@@ -392,9 +392,14 @@ xdevice_get_dimensions (int    deviceid,
         guint *value, w, h;
         int i, n_info;
 
+        gdk_error_trap_push ();
+
         info = XIQueryDevice (GDK_DISPLAY_XDISPLAY (display), deviceid, &n_info);
         *width = *height = w = h = 0;
 
+        if (gdk_error_trap_pop ())
+                return FALSE;
+
         if (!info)
                 return FALSE;
 
diff --git a/plugins/wacom/gsd-wacom-device.c b/plugins/wacom/gsd-wacom-device.c
index 0cf725b..03567dd 100644
--- a/plugins/wacom/gsd-wacom-device.c
+++ b/plugins/wacom/gsd-wacom-device.c
@@ -429,9 +429,12 @@ setup_property_notify (GsdWacomDevice *device)
        XISetMask (evmask.mask, XI_PropertyEvent);
 
        dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
-       XISelectEvents (dpy, DefaultRootWindow (dpy), &evmask, 1);
 
+       gdk_error_trap_push ();
+       XISelectEvents (dpy, DefaultRootWindow (dpy), &evmask, 1);
        g_free (evmask.mask);
+       if (gdk_error_trap_pop ())
+               return TRUE;
 
        gdk_window_add_filter (NULL,
                               (GdkFilterFunc) filter_events,
diff --git a/plugins/wacom/gsd-wacom-manager.c b/plugins/wacom/gsd-wacom-manager.c
index 259c859..88adc35 100644
--- a/plugins/wacom/gsd-wacom-manager.c
+++ b/plugins/wacom/gsd-wacom-manager.c
@@ -383,8 +383,8 @@ set_absolute (GsdWacomDevice  *device,
        gdk_error_trap_push ();
        XSetDeviceMode (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), xdev, is_absolute ? Absolute : 
Relative);
        if (gdk_error_trap_pop ())
-               g_error ("Failed to set mode \"%s\" for \"%s\".",
-                        is_absolute ? "Absolute" : "Relative", gsd_wacom_device_get_tool_name (device));
+               g_warning ("Failed to set mode \"%s\" for \"%s\".",
+                          is_absolute ? "Absolute" : "Relative", gsd_wacom_device_get_tool_name (device));
        xdevice_close (xdev);
 }
 


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