summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2012-06-20 07:19:05 -0400
committerMatthias Clasen <mclasen@redhat.com>2012-06-20 07:22:12 -0400
commite3ca87784ea52d6008fcd34bf85066cb7d8b8497 (patch)
tree332a848e541d1d88e58b767f339578180fd5272d
parentd571719a3dbefbc12097d67fb13e6b0e2007efb3 (diff)
downloadclutter-e3ca87784ea52d6008fcd34bf85066cb7d8b8497.tar.gz
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
-rw-r--r--clutter/x11/clutter-device-manager-xi2.c15
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 73e99af98..b5bf2e48b 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;