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
This commit is contained in:
Matthias Clasen 2012-06-20 07:19:05 -04:00
parent d571719a3d
commit e3ca87784e

View File

@ -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;