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



commit 13c15d85a9acf590b34940fa673669ef3b549ceb
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 3907c70..ee19ef5 100644
--- a/plugins/common/gsd-input-helper.c
+++ b/plugins/common/gsd-input-helper.c
@@ -665,9 +665,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 e06699a..5182d7c 100644
--- a/plugins/wacom/gsd-wacom-device.c
+++ b/plugins/wacom/gsd-wacom-device.c
@@ -423,9 +423,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 5194a23..c3c4193 100644
--- a/plugins/wacom/gsd-wacom-manager.c
+++ b/plugins/wacom/gsd-wacom-manager.c
@@ -359,8 +359,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]