diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2015-02-04 16:36:23 +0100 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2016-04-05 18:56:34 +0200 |
commit | 7053fdbf7ec7b868226cd97b02587a8285d64680 (patch) | |
tree | 91f2536dc877e9671c46e2b5e586c757f13f5e1b | |
parent | 2a9315492000a2104f8a6f95e286fb17df775cf1 (diff) | |
download | clutter-7053fdbf7ec7b868226cd97b02587a8285d64680.tar.gz |
input-device: Disconnect signals on actors where the device has a cursor
Otherwise the signals are left dangling if the device is removed, causing
possible invalid memory accesses afterwards.
-rw-r--r-- | clutter/clutter-input-device.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/clutter/clutter-input-device.c b/clutter/clutter-input-device.c index d552d9d9e..d9fd4f5d1 100644 --- a/clutter/clutter-input-device.c +++ b/clutter/clutter-input-device.c @@ -73,7 +73,11 @@ enum }; static void _clutter_input_device_free_touch_info (gpointer data); - +static void on_cursor_actor_destroy (ClutterActor *actor, + ClutterInputDevice *device); +static void on_cursor_actor_reactive_changed (ClutterActor *actor, + GParamSpec *pspec, + ClutterInputDevice *device); static GParamSpec *obj_props[PROP_LAST] = { NULL, }; @@ -103,6 +107,18 @@ clutter_input_device_dispose (GObject *gobject) g_clear_pointer (&device->scroll_info, g_array_unref); g_clear_pointer (&device->touch_sequences_info, g_hash_table_unref); + if (device->cursor_actor) + { + g_signal_handlers_disconnect_by_func (device->cursor_actor, + G_CALLBACK (on_cursor_actor_destroy), + device); + g_signal_handlers_disconnect_by_func (device->cursor_actor, + G_CALLBACK (on_cursor_actor_reactive_changed), + device); + _clutter_actor_set_has_pointer (device->cursor_actor, FALSE); + device->cursor_actor = NULL; + } + if (device->inv_touch_sequence_actors) { GHashTableIter iter; @@ -110,7 +126,16 @@ clutter_input_device_dispose (GObject *gobject) g_hash_table_iter_init (&iter, device->inv_touch_sequence_actors); while (g_hash_table_iter_next (&iter, &key, &value)) - g_list_free (value); + { + g_signal_handlers_disconnect_by_func (key, + G_CALLBACK (on_cursor_actor_destroy), + device); + g_signal_handlers_disconnect_by_func (device->cursor_actor, + G_CALLBACK (on_cursor_actor_reactive_changed), + device); + _clutter_actor_set_has_pointer (key, FALSE); + g_list_free (value); + } g_hash_table_unref (device->inv_touch_sequence_actors); device->inv_touch_sequence_actors = NULL; @@ -598,12 +623,6 @@ _clutter_input_device_get_actor (ClutterInputDevice *device, return info->actor; } -static void on_cursor_actor_destroy (ClutterActor *actor, - ClutterInputDevice *device); -static void on_cursor_actor_reactive_changed (ClutterActor *actor, - GParamSpec *pspec, - ClutterInputDevice *device); - static void _clutter_input_device_associate_actor (ClutterInputDevice *device, ClutterEventSequence *sequence, |