mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 10:00:45 -05:00
x11: trap errors when calling XIQueryDevice
Devices can disappear at any time, causing XIQueryDevice to throw an error. At the same time, plug a memory leak. https://bugzilla.gnome.org/show_bug.cgi?id=701974
This commit is contained in:
parent
da6abc6fc9
commit
d343cc6289
@ -408,10 +408,16 @@ translate_hierarchy_event (ClutterBackendX11 *backend_x11,
|
|||||||
|
|
||||||
CLUTTER_NOTE (EVENT, "Hierarchy event: device enabled");
|
CLUTTER_NOTE (EVENT, "Hierarchy event: device enabled");
|
||||||
|
|
||||||
|
clutter_x11_trap_x_errors ();
|
||||||
info = XIQueryDevice (backend_x11->xdpy,
|
info = XIQueryDevice (backend_x11->xdpy,
|
||||||
ev->info[i].deviceid,
|
ev->info[i].deviceid,
|
||||||
&n_devices);
|
&n_devices);
|
||||||
add_device (manager_xi2, backend_x11, &info[0], FALSE);
|
clutter_x11_untrap_x_errors ();
|
||||||
|
if (info != NULL)
|
||||||
|
{
|
||||||
|
add_device (manager_xi2, backend_x11, &info[0], FALSE);
|
||||||
|
XIFreeDeviceInfo (info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (ev->info[i].flags & XIDeviceDisabled)
|
else if (ev->info[i].flags & XIDeviceDisabled)
|
||||||
{
|
{
|
||||||
@ -448,16 +454,24 @@ translate_hierarchy_event (ClutterBackendX11 *backend_x11,
|
|||||||
/* and attach the slave to the new master if needed */
|
/* and attach the slave to the new master if needed */
|
||||||
if (ev->info[i].flags & XISlaveAttached)
|
if (ev->info[i].flags & XISlaveAttached)
|
||||||
{
|
{
|
||||||
|
clutter_x11_trap_x_errors ();
|
||||||
info = XIQueryDevice (backend_x11->xdpy,
|
info = XIQueryDevice (backend_x11->xdpy,
|
||||||
ev->info[i].deviceid,
|
ev->info[i].deviceid,
|
||||||
&n_devices);
|
&n_devices);
|
||||||
master = g_hash_table_lookup (manager_xi2->devices_by_id,
|
clutter_x11_untrap_x_errors ();
|
||||||
GINT_TO_POINTER (info->attachment));
|
if (info != NULL)
|
||||||
_clutter_input_device_set_associated_device (slave, master);
|
{
|
||||||
_clutter_input_device_add_slave (master, slave);
|
master = g_hash_table_lookup (manager_xi2->devices_by_id,
|
||||||
|
GINT_TO_POINTER (info->attachment));
|
||||||
|
if (master != NULL)
|
||||||
|
{
|
||||||
|
_clutter_input_device_set_associated_device (slave, master);
|
||||||
|
_clutter_input_device_add_slave (master, slave);
|
||||||
|
|
||||||
send_changed = TRUE;
|
send_changed = TRUE;
|
||||||
XIFreeDeviceInfo (info);
|
}
|
||||||
|
XIFreeDeviceInfo (info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (send_changed)
|
if (send_changed)
|
||||||
|
Loading…
Reference in New Issue
Block a user