[clutter] XI2: Avoid a crash in event translation



commit e3ca87784ea52d6008fcd34bf85066cb7d8b8497
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jun 20 07:19:05 2012 -0400

    XI2: Avoid a crash in event translation
    
    It is possible that we get a DeviceChanged event for a device
    that is not in the hash table yet. E.g. I've seen this when
    using xrandr to change screen resolution. Prevent a crash in
    this case.
    
    https://bugzilla.gnome.org/review?bug=678439

 clutter/x11/clutter-device-manager-xi2.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/clutter/x11/clutter-device-manager-xi2.c b/clutter/x11/clutter-device-manager-xi2.c
index 73e99af..b5bf2e4 100644
--- a/clutter/x11/clutter-device-manager-xi2.c
+++ b/clutter/x11/clutter-device-manager-xi2.c
@@ -733,12 +733,15 @@ clutter_device_manager_xi2_translate_event (ClutterEventTranslator *translator,
 
         device = g_hash_table_lookup (manager_xi2->devices_by_id,
                                       GINT_TO_POINTER (xev->deviceid));
-        _clutter_input_device_reset_axes (device);
-        _clutter_input_device_reset_scroll_info (device);
-        translate_device_classes (backend_x11->xdpy,
-                                  device,
-                                  xev->classes,
-                                  xev->num_classes);
+        if (device)
+          {
+            _clutter_input_device_reset_axes (device);
+            _clutter_input_device_reset_scroll_info (device);
+            translate_device_classes (backend_x11->xdpy,
+                                      device,
+                                      xev->classes,
+                                      xev->num_classes);
+          }
       }
       retval = CLUTTER_TRANSLATE_REMOVE;
       break;



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