cleanup: Use g_clear_signal_handler() where possible

This is inspired by 98892391d7 where the usage of
`g_signal_handler_disconnect()` without resetting the corresponding
handler id later resulted in a bug. Using `g_clear_signal_handler()`
makes sure we avoid similar bugs and is almost always the better
alternative. We use it for new code, let's clean up the old code to
also use it.

A further benefit is that it can get called even if the passed id is
0, allowing us to remove a lot of now unnessecary checks, and the fact
that `g_clear_signal_handler()` checks for the right type size, forcing us
to clean up all places where we used `guint` instead of `gulong`.

No functional changes intended here and all changes should be trivial,
thus bundled in one big commit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/940
This commit is contained in:
Robert Mader 2019-11-16 01:25:52 +01:00 committed by Florian Müllner
parent 22d1febf3c
commit 92375c75f8
45 changed files with 168 additions and 303 deletions

View File

@ -51,7 +51,7 @@
struct _ClutterActorMetaPrivate
{
ClutterActor *actor;
guint destroy_id;
gulong destroy_id;
gchar *name;
@ -91,11 +91,7 @@ clutter_actor_meta_real_set_actor (ClutterActorMeta *meta,
if (meta->priv->actor == actor)
return;
if (meta->priv->destroy_id != 0)
{
g_signal_handler_disconnect (meta->priv->actor, meta->priv->destroy_id);
meta->priv->destroy_id = 0;
}
g_clear_signal_handler (&meta->priv->destroy_id, meta->priv->actor);
meta->priv->actor = actor;
@ -162,8 +158,8 @@ clutter_actor_meta_finalize (GObject *gobject)
{
ClutterActorMetaPrivate *priv = CLUTTER_ACTOR_META (gobject)->priv;
if (priv->destroy_id != 0 && priv->actor != NULL)
g_signal_handler_disconnect (priv->actor, priv->destroy_id);
if (priv->actor != NULL)
g_clear_signal_handler (&priv->destroy_id, priv->actor);
g_free (priv->name);

View File

@ -808,8 +808,8 @@ struct _ClutterActorPrivate
gpointer create_child_data;
GDestroyNotify create_child_notify;
guint resolution_changed_id;
guint font_changed_id;
gulong resolution_changed_id;
gulong font_changed_id;
/* bitfields: KEEP AT THE END */
@ -6141,17 +6141,8 @@ clutter_actor_dispose (GObject *object)
g_assert (!CLUTTER_ACTOR_IS_REALIZED (self));
}
if (priv->resolution_changed_id)
{
g_signal_handler_disconnect (backend, priv->resolution_changed_id);
priv->resolution_changed_id = 0;
}
if (priv->font_changed_id)
{
g_signal_handler_disconnect (backend, priv->font_changed_id);
priv->font_changed_id = 0;
}
g_clear_signal_handler (&priv->resolution_changed_id, backend);
g_clear_signal_handler (&priv->font_changed_id, backend);
g_clear_object (&priv->pango_context);
g_clear_object (&priv->actions);
@ -19009,7 +19000,7 @@ transition_closure_free (gpointer data)
* so that we don't end up inside on_transition_stopped() from
* a call to g_hash_table_remove().
*/
g_signal_handler_disconnect (clos->transition, clos->completed_id);
g_clear_signal_handler (&clos->completed_id, clos->transition);
if (clutter_timeline_is_playing (timeline))
clutter_timeline_stop (timeline);

View File

@ -105,8 +105,8 @@ struct _ClutterClickActionPrivate
{
ClutterActor *stage;
guint event_id;
guint capture_id;
gulong event_id;
gulong capture_id;
guint long_press_id;
gint long_press_threshold;
@ -202,11 +202,7 @@ click_action_emit_long_press (gpointer data)
CLUTTER_LONG_PRESS_ACTIVATE,
&result);
if (priv->capture_id != 0)
{
g_signal_handler_disconnect (priv->stage, priv->capture_id);
priv->capture_id = 0;
}
g_clear_signal_handler (&priv->capture_id, priv->stage);
click_action_set_pressed (action, FALSE);
click_action_set_held (action, FALSE);
@ -375,11 +371,7 @@ on_captured_event (ClutterActor *stage,
click_action_cancel_long_press (action);
/* disconnect the capture */
if (priv->capture_id != 0)
{
g_signal_handler_disconnect (priv->stage, priv->capture_id);
priv->capture_id = 0;
}
g_clear_signal_handler (&priv->capture_id, priv->stage);
if (priv->long_press_id != 0)
{
@ -453,7 +445,7 @@ clutter_click_action_set_actor (ClutterActorMeta *meta,
ClutterActor *old_actor = clutter_actor_meta_get_actor (meta);
if (old_actor != NULL)
g_signal_handler_disconnect (old_actor, priv->event_id);
g_clear_signal_handler (&priv->event_id, old_actor);
priv->event_id = 0;
}
@ -461,7 +453,7 @@ clutter_click_action_set_actor (ClutterActorMeta *meta,
if (priv->capture_id != 0)
{
if (priv->stage != NULL)
g_signal_handler_disconnect (priv->stage, priv->capture_id);
g_clear_signal_handler (&priv->capture_id, priv->stage);
priv->capture_id = 0;
priv->stage = NULL;
@ -545,18 +537,10 @@ clutter_click_action_dispose (GObject *gobject)
{
ClutterClickActionPrivate *priv = CLUTTER_CLICK_ACTION (gobject)->priv;
if (priv->event_id)
{
g_signal_handler_disconnect (clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (gobject)),
priv->event_id);
priv->event_id = 0;
}
g_clear_signal_handler (&priv->event_id,
clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (gobject)));
if (priv->capture_id)
{
g_signal_handler_disconnect (priv->stage, priv->capture_id);
priv->capture_id = 0;
}
g_clear_signal_handler (&priv->capture_id, priv->stage);
if (priv->long_press_id)
{
@ -760,11 +744,7 @@ clutter_click_action_release (ClutterClickAction *action)
return;
/* disconnect the capture */
if (priv->capture_id != 0)
{
g_signal_handler_disconnect (priv->stage, priv->capture_id);
priv->capture_id = 0;
}
g_clear_signal_handler (&priv->capture_id, priv->stage);
click_action_cancel_long_press (action);
click_action_set_held (action, FALSE);

View File

@ -400,8 +400,7 @@ clutter_clone_set_source_internal (ClutterClone *self,
if (priv->clone_source != NULL)
{
g_signal_handler_disconnect (priv->clone_source, priv->source_destroy_id);
priv->source_destroy_id = 0;
g_clear_signal_handler (&priv->source_destroy_id, priv->clone_source);
_clutter_actor_detach_clone (priv->clone_source, CLUTTER_ACTOR (self));
g_object_unref (priv->clone_source);
priv->clone_source = NULL;

View File

@ -147,7 +147,7 @@ clutter_deform_effect_set_actor (ClutterActorMeta *meta,
ClutterActor *old_actor = clutter_actor_meta_get_actor (meta);
if (old_actor != NULL)
g_signal_handler_disconnect (old_actor, priv->allocation_id);
g_clear_signal_handler (&priv->allocation_id, old_actor);
priv->allocation_id = 0;
}

View File

@ -315,11 +315,7 @@ emit_drag_end (ClutterDragAction *action,
goto out;
/* disconnect the capture */
if (priv->capture_id != 0)
{
g_signal_handler_disconnect (priv->stage, priv->capture_id);
priv->capture_id = 0;
}
g_clear_signal_handler (&priv->capture_id, priv->stage);
clutter_stage_set_motion_events_enabled (priv->stage,
priv->motion_events_enabled);
@ -478,8 +474,8 @@ clutter_drag_action_set_actor (ClutterActorMeta *meta,
old_actor = clutter_actor_meta_get_actor (meta);
if (old_actor != NULL)
{
g_signal_handler_disconnect (old_actor, priv->button_press_id);
g_signal_handler_disconnect (old_actor, priv->touch_begin_id);
g_clear_signal_handler (&priv->button_press_id, old_actor);
g_clear_signal_handler (&priv->touch_begin_id, old_actor);
}
priv->button_press_id = 0;
@ -489,7 +485,7 @@ clutter_drag_action_set_actor (ClutterActorMeta *meta,
if (priv->capture_id != 0)
{
if (priv->stage != NULL)
g_signal_handler_disconnect (priv->stage, priv->capture_id);
g_clear_signal_handler (&priv->capture_id, priv->stage);
priv->capture_id = 0;
priv->stage = NULL;
@ -668,7 +664,7 @@ clutter_drag_action_dispose (GObject *gobject)
priv->motion_events_enabled);
if (priv->stage != NULL)
g_signal_handler_disconnect (priv->stage, priv->capture_id);
g_clear_signal_handler (&priv->capture_id, priv->stage);
priv->capture_id = 0;
priv->stage = NULL;
@ -681,8 +677,8 @@ clutter_drag_action_dispose (GObject *gobject)
actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (gobject));
if (actor != NULL)
{
g_signal_handler_disconnect (actor, priv->button_press_id);
g_signal_handler_disconnect (actor, priv->touch_begin_id);
g_clear_signal_handler (&priv->button_press_id, actor);
g_clear_signal_handler (&priv->touch_begin_id, actor);
}
priv->button_press_id = 0;

View File

@ -107,7 +107,7 @@ drop_target_free (gpointer _data)
{
DropTarget *data = _data;
g_signal_handler_disconnect (data->stage, data->capture_id);
g_clear_signal_handler (&data->capture_id, data->stage);
g_hash_table_destroy (data->actions);
g_free (data);
}
@ -326,12 +326,10 @@ clutter_drop_action_set_actor (ClutterActorMeta *meta,
{
drop_action_unregister (CLUTTER_DROP_ACTION (meta));
if (priv->mapped_id != 0)
g_signal_handler_disconnect (priv->actor, priv->mapped_id);
g_clear_signal_handler (&priv->mapped_id, priv->actor);
priv->stage = NULL;
priv->actor = NULL;
priv->mapped_id = 0;
}
priv->actor = actor;

View File

@ -118,7 +118,7 @@ struct _ClutterGestureActionPrivate
gint requested_nb_points;
GArray *points;
guint actor_capture_id;
gulong actor_capture_id;
gulong stage_capture_id;
ClutterGestureTriggerEdge edge;
@ -308,11 +308,7 @@ cancel_gesture (ClutterGestureAction *action)
priv->in_gesture = FALSE;
if (priv->stage_capture_id != 0)
{
g_signal_handler_disconnect (priv->stage, priv->stage_capture_id);
priv->stage_capture_id = 0;
}
g_clear_signal_handler (&priv->stage_capture_id, priv->stage);
actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (action));
g_signal_emit (action, gesture_signals[GESTURE_CANCEL], 0, actor);
@ -481,11 +477,8 @@ stage_captured_event_cb (ClutterActor *stage,
break;
}
if (priv->points->len == 0 && priv->stage_capture_id)
{
g_signal_handler_disconnect (priv->stage, priv->stage_capture_id);
priv->stage_capture_id = 0;
}
if (priv->points->len == 0)
g_clear_signal_handler (&priv->stage_capture_id, priv->stage);
return CLUTTER_EVENT_PROPAGATE;
}
@ -538,7 +531,7 @@ clutter_gesture_action_set_actor (ClutterActorMeta *meta,
ClutterActor *old_actor = clutter_actor_meta_get_actor (meta);
if (old_actor != NULL)
g_signal_handler_disconnect (old_actor, priv->actor_capture_id);
g_clear_signal_handler (&priv->actor_capture_id, old_actor);
priv->actor_capture_id = 0;
}
@ -546,7 +539,7 @@ clutter_gesture_action_set_actor (ClutterActorMeta *meta,
if (priv->stage_capture_id != 0)
{
if (priv->stage != NULL)
g_signal_handler_disconnect (priv->stage, priv->stage_capture_id);
g_clear_signal_handler (&priv->stage_capture_id, priv->stage);
priv->stage_capture_id = 0;
priv->stage = NULL;

View File

@ -178,17 +178,17 @@ struct _ClutterTextPrivate
guint password_hint_timeout;
/* Signal handler for when the backend changes its font settings */
guint settings_changed_id;
gulong settings_changed_id;
/* Signal handler for when the :text-direction changes */
guint direction_changed_id;
gulong direction_changed_id;
ClutterInputFocus *input_focus;
ClutterInputContentHintFlags input_hints;
ClutterInputContentPurpose input_purpose;
/* Signal handler for when the :resource-scale changes */
guint resource_scale_changed_id;
gulong resource_scale_changed_id;
/* bitfields */
guint alignment : 2;
@ -1758,24 +1758,10 @@ clutter_text_dispose (GObject *gobject)
/* get rid of the entire cache */
clutter_text_dirty_cache (self);
if (priv->direction_changed_id)
{
g_signal_handler_disconnect (self, priv->direction_changed_id);
priv->direction_changed_id = 0;
}
if (priv->resource_scale_changed_id)
{
g_signal_handler_disconnect (self, priv->resource_scale_changed_id);
priv->resource_scale_changed_id = 0;
}
if (priv->settings_changed_id)
{
g_signal_handler_disconnect (clutter_get_default_backend (),
priv->settings_changed_id);
priv->settings_changed_id = 0;
}
g_clear_signal_handler (&priv->direction_changed_id, self);
g_clear_signal_handler (&priv->resource_scale_changed_id, self);
g_clear_signal_handler (&priv->settings_changed_id,
clutter_get_default_backend ());
if (priv->password_hint_id)
{

View File

@ -205,7 +205,7 @@ test_texture_pixmap_x11 (TestUtilsGTestFixture *fixture,
TestState state;
unsigned int idle_handler;
unsigned int paint_handler;
unsigned long paint_handler;
state.frame_count = 0;
state.stage = clutter_stage_get_default ();
@ -226,7 +226,7 @@ test_texture_pixmap_x11 (TestUtilsGTestFixture *fixture,
clutter_main ();
g_signal_handler_disconnect (state.stage, paint_handler);
g_clear_signal_handler (&paint_handler, state.stage);
g_source_remove (idle_handler);

View File

@ -144,7 +144,7 @@ struct _MetaBackendPrivate
gboolean is_pointer_position_initialized;
guint device_update_idle_id;
guint keymap_state_changed_id;
gulong keymap_state_changed_id;
GHashTable *device_monitors;
@ -184,7 +184,7 @@ meta_backend_finalize (GObject *object)
ClutterKeymap *keymap;
keymap = clutter_backend_get_keymap (priv->clutter_backend);
g_signal_handler_disconnect (keymap, priv->keymap_state_changed_id);
g_clear_signal_handler (&priv->keymap_state_changed_id, keymap);
}
g_list_free_full (priv->gpus, g_object_unref);

View File

@ -50,7 +50,7 @@ struct _CurrentToolInfo
ClutterInputDevice *device;
ClutterInputDeviceTool *tool;
GSettings *settings;
guint changed_id;
gulong changed_id;
};
struct _DeviceMappingInfo
@ -58,7 +58,7 @@ struct _DeviceMappingInfo
MetaInputSettings *input_settings;
ClutterInputDevice *device;
GSettings *settings;
guint changed_id;
gulong changed_id;
#ifdef HAVE_LIBWACOM
WacomDevice *wacom_device;
#endif
@ -69,7 +69,7 @@ struct _MetaInputSettingsPrivate
{
ClutterDeviceManager *device_manager;
MetaMonitorManager *monitor_manager;
guint monitors_changed_id;
gulong monitors_changed_id;
GSettings *mouse_settings;
GSettings *touchpad_settings;
@ -168,12 +168,8 @@ meta_input_settings_dispose (GObject *object)
g_clear_pointer (&priv->mappable_devices, g_hash_table_unref);
g_clear_pointer (&priv->current_tools, g_hash_table_unref);
if (priv->monitors_changed_id && priv->monitor_manager)
{
g_signal_handler_disconnect (priv->monitor_manager,
priv->monitors_changed_id);
priv->monitors_changed_id = 0;
}
if (priv->monitor_manager)
g_clear_signal_handler (&priv->monitors_changed_id, priv->monitor_manager);
g_clear_object (&priv->monitor_manager);
@ -1555,7 +1551,7 @@ device_mapping_info_free (DeviceMappingInfo *info)
if (info->wacom_device)
libwacom_destroy (info->wacom_device);
#endif
g_signal_handler_disconnect (info->settings, info->changed_id);
g_clear_signal_handler (&info->changed_id, info->settings);
g_object_unref (info->settings);
g_free (info->group_modes);
g_slice_free (DeviceMappingInfo, info);
@ -1812,7 +1808,7 @@ current_tool_info_new (MetaInputSettings *input_settings,
static void
current_tool_info_free (CurrentToolInfo *info)
{
g_signal_handler_disconnect (info->settings, info->changed_id);
g_clear_signal_handler (&info->changed_id, info->settings);
g_free (info);
}

View File

@ -802,8 +802,8 @@ meta_monitor_manager_finalize (GObject *object)
g_list_free_full (manager->logical_monitors, g_object_unref);
g_signal_handler_disconnect (manager->backend,
manager->experimental_features_changed_handler_id);
g_clear_signal_handler (&manager->experimental_features_changed_handler_id,
manager->backend);
G_OBJECT_CLASS (meta_monitor_manager_parent_class)->finalize (object);
}

View File

@ -151,8 +151,8 @@ meta_remote_desktop_session_close (MetaRemoteDesktopSession *session)
if (session->screen_cast_session)
{
g_signal_handler_disconnect (session->screen_cast_session,
session->screen_cast_session_closed_handler_id);
g_clear_signal_handler (&session->screen_cast_session_closed_handler_id,
session->screen_cast_session);
meta_screen_cast_session_close (session->screen_cast_session);
session->screen_cast_session = NULL;
}

View File

@ -331,19 +331,10 @@ meta_screen_cast_monitor_stream_src_disable (MetaScreenCastStreamSrc *src)
uninhibit_hw_cursor (monitor_src);
}
if (monitor_src->cursor_moved_handler_id)
{
g_signal_handler_disconnect (cursor_tracker,
monitor_src->cursor_moved_handler_id);
monitor_src->cursor_moved_handler_id = 0;
}
if (monitor_src->cursor_changed_handler_id)
{
g_signal_handler_disconnect (cursor_tracker,
monitor_src->cursor_changed_handler_id);
monitor_src->cursor_changed_handler_id = 0;
}
g_clear_signal_handler (&monitor_src->cursor_moved_handler_id,
cursor_tracker);
g_clear_signal_handler (&monitor_src->cursor_changed_handler_id,
cursor_tracker);
}
static gboolean

View File

@ -253,25 +253,14 @@ meta_screen_cast_window_stream_src_stop (MetaScreenCastWindowStreamSrc *window_s
if (!window_src->screen_cast_window)
return;
if (window_src->screen_cast_window_damaged_handler_id)
g_signal_handler_disconnect (window_src->screen_cast_window,
window_src->screen_cast_window_damaged_handler_id);
window_src->screen_cast_window_damaged_handler_id = 0;
if (window_src->screen_cast_window_destroyed_handler_id)
g_signal_handler_disconnect (window_src->screen_cast_window,
window_src->screen_cast_window_destroyed_handler_id);
window_src->screen_cast_window_destroyed_handler_id = 0;
if (window_src->cursor_moved_handler_id)
g_signal_handler_disconnect (cursor_tracker,
window_src->cursor_moved_handler_id);
window_src->cursor_moved_handler_id = 0;
if (window_src->cursor_changed_handler_id)
g_signal_handler_disconnect (cursor_tracker,
window_src->cursor_changed_handler_id);
window_src->cursor_changed_handler_id = 0;
g_clear_signal_handler (&window_src->screen_cast_window_damaged_handler_id,
window_src->screen_cast_window);
g_clear_signal_handler (&window_src->screen_cast_window_destroyed_handler_id,
window_src->screen_cast_window);
g_clear_signal_handler (&window_src->cursor_moved_handler_id,
cursor_tracker);
g_clear_signal_handler (&window_src->cursor_changed_handler_id,
cursor_tracker);
}
static void

View File

@ -195,9 +195,8 @@ meta_screen_cast_window_stream_finalize (GObject *object)
MetaScreenCastWindowStream *window_stream =
META_SCREEN_CAST_WINDOW_STREAM (object);
if (window_stream->window_unmanaged_handler_id)
g_signal_handler_disconnect (window_stream->window,
window_stream->window_unmanaged_handler_id);
g_clear_signal_handler (&window_stream->window_unmanaged_handler_id,
window_stream->window);
G_OBJECT_CLASS (meta_screen_cast_window_stream_parent_class)->finalize (object);
}

View File

@ -72,7 +72,7 @@ struct _MetaBackendNative
MetaKms *kms;
MetaBarrierManagerNative *barrier_manager;
guint udev_device_added_handler_id;
gulong udev_device_added_handler_id;
};
static GInitableIface *initable_parent_iface;
@ -601,9 +601,7 @@ connect_udev_device_added_handler (MetaBackendNative *native)
static void
disconnect_udev_device_added_handler (MetaBackendNative *native)
{
g_signal_handler_disconnect (native->udev,
native->udev_device_added_handler_id);
native->udev_device_added_handler_id = 0;
g_clear_signal_handler (&native->udev_device_added_handler_id, native->udev);
}
static gboolean

View File

@ -87,8 +87,8 @@ struct _MetaDeviceManagerNativePrivate
gpointer relative_motion_filter_user_data;
ClutterStageManager *stage_manager;
guint stage_added_handler;
guint stage_removed_handler;
gulong stage_added_handler;
gulong stage_removed_handler;
GSList *event_filters;
@ -1947,19 +1947,8 @@ meta_device_manager_native_dispose (GObject *object)
manager_evdev = META_DEVICE_MANAGER_NATIVE (object);
priv = manager_evdev->priv;
if (priv->stage_added_handler)
{
g_signal_handler_disconnect (priv->stage_manager,
priv->stage_added_handler);
priv->stage_added_handler = 0;
}
if (priv->stage_removed_handler)
{
g_signal_handler_disconnect (priv->stage_manager,
priv->stage_removed_handler);
priv->stage_removed_handler = 0;
}
g_clear_signal_handler (&priv->stage_added_handler, priv->stage_manager);
g_clear_signal_handler (&priv->stage_removed_handler, priv->stage_manager);
if (priv->stage_manager)
{
@ -2048,9 +2037,7 @@ meta_device_manager_native_stage_added_cb (ClutterStageManager *manager,
/* We only want to do this once so we can catch the default
stage. If the application has multiple stages then it will need
to manage the stage of the input devices itself */
g_signal_handler_disconnect (priv->stage_manager,
priv->stage_added_handler);
priv->stage_added_handler = 0;
g_clear_signal_handler (&priv->stage_added_handler, priv->stage_manager);
}
static void

View File

@ -158,8 +158,8 @@ struct _MetaKms
MetaBackend *backend;
guint hotplug_handler_id;
guint removed_handler_id;
gulong hotplug_handler_id;
gulong removed_handler_id;
MetaKmsImpl *impl;
gboolean in_impl_task;
@ -588,11 +588,8 @@ meta_kms_finalize (GObject *object)
g_list_free_full (kms->devices, g_object_unref);
if (kms->hotplug_handler_id)
g_signal_handler_disconnect (udev, kms->hotplug_handler_id);
if (kms->removed_handler_id)
g_signal_handler_disconnect (udev, kms->removed_handler_id);
g_clear_signal_handler (&kms->hotplug_handler_id, udev);
g_clear_signal_handler (&kms->removed_handler_id, udev);
G_OBJECT_CLASS (meta_kms_parent_class)->finalize (object);
}

View File

@ -46,7 +46,7 @@ struct _MetaUdev
GUdevClient *gudev_client;
guint uevent_handler_id;
gulong uevent_handler_id;
};
G_DEFINE_TYPE (MetaUdev, meta_udev, G_TYPE_OBJECT)
@ -187,7 +187,7 @@ meta_udev_finalize (GObject *object)
{
MetaUdev *udev = META_UDEV (object);
g_signal_handler_disconnect (udev->gudev_client, udev->uevent_handler_id);
g_clear_signal_handler (&udev->uevent_handler_id, udev->gudev_client);
g_clear_object (&udev->gudev_client);
G_OBJECT_CLASS (meta_udev_parent_class)->finalize (object);

View File

@ -326,10 +326,7 @@ meta_dnd_wayland_handle_end_modal (MetaCompositor *compositor)
return;
for (i = 0; i < G_N_ELEMENTS (priv->handler_id); i++)
{
g_signal_handler_disconnect (stage, priv->handler_id[i]);
priv->handler_id[i] = 0;
}
g_clear_signal_handler (&priv->handler_id[i], stage);
priv->compositor = NULL;
priv->wl_compositor = NULL;

View File

@ -54,9 +54,9 @@ struct _GestureActionData
{
ClutterGestureAction *gesture;
MetaSequenceState state;
guint gesture_begin_id;
guint gesture_end_id;
guint gesture_cancel_id;
gulong gesture_begin_id;
gulong gesture_end_id;
gulong gesture_cancel_id;
};
struct _MetaGestureTrackerPrivate
@ -334,9 +334,9 @@ cancel_and_unref_gesture_cb (ClutterGestureAction *action)
static void
clear_gesture_data (GestureActionData *data)
{
g_signal_handler_disconnect (data->gesture, data->gesture_begin_id);
g_signal_handler_disconnect (data->gesture, data->gesture_end_id);
g_signal_handler_disconnect (data->gesture, data->gesture_cancel_id);
g_clear_signal_handler (&data->gesture_begin_id, data->gesture);
g_clear_signal_handler (&data->gesture_end_id, data->gesture);
g_clear_signal_handler (&data->gesture_cancel_id, data->gesture);
/* Defer cancellation to an idle, as it may happen within event handling */
g_idle_add ((GSourceFunc) cancel_and_unref_gesture_cb, data->gesture);

View File

@ -43,7 +43,7 @@ struct _MetaPlayRequest
{
ca_proplist *props;
uint32_t id;
guint cancel_id;
gulong cancel_id;
GCancellable *cancellable;
MetaSoundPlayer *player;
};
@ -119,8 +119,8 @@ finish_cb (ca_context *context,
if (error_code != CA_ERROR_CANCELED)
g_cancellable_disconnect (req->cancellable, req->cancel_id);
else if (req->cancellable != NULL && req->cancel_id != 0)
g_signal_handler_disconnect (req->cancellable, req->cancel_id);
else if (req->cancellable != NULL)
g_clear_signal_handler (&req->cancel_id, req->cancellable);
meta_play_request_free (req);
}

View File

@ -1992,7 +1992,7 @@ gboolean
meta_prefs_remove_keybinding (const char *name)
{
MetaKeyPref *pref;
guint id;
gulong id;
pref = g_hash_table_lookup (key_bindings, name);
if (!pref)
@ -2008,7 +2008,7 @@ meta_prefs_remove_keybinding (const char *name)
}
id = GPOINTER_TO_UINT (g_object_steal_data (G_OBJECT (pref->settings), name));
g_signal_handler_disconnect (pref->settings, id);
g_clear_signal_handler (&id, pref->settings);
g_hash_table_remove (key_bindings, name);

View File

@ -345,7 +345,7 @@ clutter_test_check_actor_at_point (ClutterActor *stage,
ClutterActor **result)
{
ValidateData *data;
guint press_id = 0;
gulong press_id = 0;
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
g_return_val_if_fail (point != NULL, FALSE);
@ -377,8 +377,7 @@ clutter_test_check_actor_at_point (ClutterActor *stage,
*result = data->result;
if (press_id != 0)
g_signal_handler_disconnect (stage, press_id);
g_clear_signal_handler (&press_id, stage);
g_free (data);
@ -409,7 +408,7 @@ clutter_test_check_color_at_point (ClutterActor *stage,
ValidateData *data;
gboolean retval;
guint8 *buffer;
guint press_id = 0;
gulong press_id = 0;
g_return_val_if_fail (CLUTTER_IS_STAGE (stage), FALSE);
g_return_val_if_fail (point != NULL, FALSE);
@ -439,8 +438,7 @@ clutter_test_check_color_at_point (ClutterActor *stage,
while (!data->was_painted)
g_main_context_iteration (NULL, TRUE);
if (press_id != 0)
g_signal_handler_disconnect (stage, press_id);
g_clear_signal_handler (&press_id, stage);
buffer = data->result;

View File

@ -156,7 +156,7 @@ static void
verify_redraw (Data *data, int expected_paint_count)
{
GMainLoop *main_loop = g_main_loop_new (NULL, TRUE);
guint paint_handler;
gulong paint_handler;
paint_handler = g_signal_connect_data (data->stage,
"paint",
@ -173,7 +173,7 @@ verify_redraw (Data *data, int expected_paint_count)
/* Wait for it to paint */
g_main_loop_run (main_loop);
g_signal_handler_disconnect (data->stage, paint_handler);
g_clear_signal_handler (&paint_handler, data->stage);
g_assert_cmpint (data->foo_actor->paint_count, ==, expected_paint_count);
}

View File

@ -32,7 +32,7 @@ typedef struct SuperOH
ClutterTimeline *timeline;
guint frame_id;
gulong frame_id;
gboolean *paint_guards;
} SuperOH;
@ -189,7 +189,7 @@ static void
stop_and_quit (ClutterActor *actor,
SuperOH *oh)
{
g_signal_handler_disconnect (oh->timeline, oh->frame_id);
g_clear_signal_handler (&oh->frame_id, oh->timeline);
clutter_timeline_stop (oh->timeline);
clutter_main_quit ();

View File

@ -363,7 +363,7 @@ typedef struct _WaitForShownData
{
GMainLoop *loop;
MetaWindow *window;
guint shown_handler_id;
gulong shown_handler_id;
} WaitForShownData;
static void
@ -405,8 +405,7 @@ test_client_wait_for_window_shown (TestClient *client,
&data,
NULL);
g_main_loop_run (data.loop);
if (data.shown_handler_id)
g_signal_handler_disconnect (window, data.shown_handler_id);
g_clear_signal_handler (&data.shown_handler_id, window);
g_main_loop_unref (data.loop);
}

View File

@ -360,9 +360,8 @@ meta_wayland_cursor_surface_set_renderer (MetaWaylandCursorSurface *cursor_surfa
if (priv->cursor_renderer)
{
g_signal_handler_disconnect (priv->cursor_renderer,
priv->cursor_painted_handler_id);
priv->cursor_painted_handler_id = 0;
g_clear_signal_handler (&priv->cursor_painted_handler_id,
priv->cursor_renderer);
g_object_unref (priv->cursor_renderer);
}
if (renderer)

View File

@ -780,8 +780,8 @@ destroy_drag_focus (struct wl_listener *listener, void *data)
grab->drag_focus_data_device = NULL;
g_signal_handler_disconnect (grab->drag_focus,
grab->drag_focus_destroy_handler_id);
g_clear_signal_handler (&grab->drag_focus_destroy_handler_id,
grab->drag_focus);
grab->drag_focus = NULL;
}
@ -852,8 +852,8 @@ meta_wayland_drag_grab_set_focus (MetaWaylandDragGrab *drag_grab,
if (drag_grab->drag_focus)
{
meta_wayland_surface_drag_dest_focus_out (drag_grab->drag_focus);
g_signal_handler_disconnect (drag_grab->drag_focus,
drag_grab->drag_focus_destroy_handler_id);
g_clear_signal_handler (&drag_grab->drag_focus_destroy_handler_id,
drag_grab->drag_focus);
drag_grab->drag_focus = NULL;
}

View File

@ -62,8 +62,8 @@ gtk_surface_destructor (struct wl_resource *resource)
{
g_object_steal_qdata (G_OBJECT (gtk_surface->surface),
quark_gtk_surface_data);
g_signal_handler_disconnect (gtk_surface->surface,
gtk_surface->configure_handler_id);
g_clear_signal_handler (&gtk_surface->configure_handler_id,
gtk_surface->surface);
}
g_free (gtk_surface);

View File

@ -55,7 +55,7 @@ surface_inhibit_shortcuts_data_set (MetaWaylandSurface *surface,
static void
surface_inhibit_shortcuts_data_destroy_dialog (InhibitShortcutsData *data)
{
g_signal_handler_disconnect (data->dialog, data->response_handler_id);
g_clear_signal_handler (&data->response_handler_id, data->dialog);
meta_inhibit_shortcuts_dialog_hide (data->dialog);
g_clear_object (&data->dialog);
}

View File

@ -51,14 +51,14 @@ zwp_keyboard_shortcuts_inhibit_destructor (struct wl_resource *resource)
{
meta_wayland_surface_cancel_inhibit_shortcuts_dialog (shortcut_inhibit->surface);
g_signal_handler_disconnect (shortcut_inhibit->surface,
shortcut_inhibit->surface_destroyed_handler);
g_clear_signal_handler (&shortcut_inhibit->surface_destroyed_handler,
shortcut_inhibit->surface);
g_signal_handler_disconnect (shortcut_inhibit->surface,
shortcut_inhibit->inhibit_shortcut_handler);
g_clear_signal_handler (&shortcut_inhibit->inhibit_shortcut_handler,
shortcut_inhibit->surface);
g_signal_handler_disconnect (shortcut_inhibit->surface,
shortcut_inhibit->restore_shortcut_handler);
g_clear_signal_handler (&shortcut_inhibit->restore_shortcut_handler,
shortcut_inhibit->surface);
meta_wayland_surface_restore_shortcuts (shortcut_inhibit->surface,
shortcut_inhibit->seat);

View File

@ -166,8 +166,7 @@ window_associated (MetaWaylandSurfaceRole *surface_role,
MetaWaylandSurface *surface = data->surface;
connect_window (data, surface->window);
g_signal_handler_disconnect (surface, data->window_associated_handler_id);
data->window_associated_handler_id = 0;
g_clear_signal_handler (&data->window_associated_handler_id, surface);
meta_wayland_pointer_constraint_maybe_enable_for_window (surface->window);
}
@ -206,17 +205,15 @@ surface_constraint_data_free (MetaWaylandSurfacePointerConstraintsData *data)
{
if (data->window)
{
g_signal_handler_disconnect (data->window,
data->appears_changed_handler_id);
g_signal_handler_disconnect (data->window,
data->raised_handler_id);
g_clear_signal_handler (&data->appears_changed_handler_id, data->window);
g_clear_signal_handler (&data->raised_handler_id, data->window);
g_object_remove_weak_pointer (G_OBJECT (data->window),
(gpointer *) &data->window);
}
else
{
g_signal_handler_disconnect (data->surface->role,
data->window_associated_handler_id);
g_clear_signal_handler (&data->window_associated_handler_id,
data->surface->role);
}
g_list_free_full (data->pointer_constraints,
@ -757,8 +754,7 @@ pending_constraint_state_applied (MetaWaylandPendingState *pending,
constraint->region = NULL;
}
g_signal_handler_disconnect (pending,
constraint_pending->applied_handler_id);
g_clear_signal_handler (&constraint_pending->applied_handler_id, pending);
remove_pending_constraint_state (constraint, pending);
/* The pointer is potentially warped by the actor paint signal callback if
@ -1158,8 +1154,8 @@ meta_wayland_pointer_constraint_finalize (GObject *object)
MetaWaylandPointerConstraint *constraint =
META_WAYLAND_POINTER_CONSTRAINT (object);
g_signal_handler_disconnect (constraint->seat->pointer,
constraint->pointer_focus_surface_handler_id);
g_clear_signal_handler (&constraint->pointer_focus_surface_handler_id,
constraint->seat->pointer);
G_OBJECT_CLASS (meta_wayland_pointer_constraint_parent_class)->finalize (object);
}

View File

@ -535,10 +535,10 @@ meta_wayland_pointer_disable (MetaWaylandPointer *pointer)
meta_wayland_pointer_on_cursor_visibility_changed,
pointer);
if (pointer->cursor_surface && pointer->cursor_surface_destroy_id)
if (pointer->cursor_surface)
{
g_signal_handler_disconnect (pointer->cursor_surface,
pointer->cursor_surface_destroy_id);
g_clear_signal_handler (&pointer->cursor_surface_destroy_id,
pointer->cursor_surface);
}
meta_wayland_pointer_cancel_grab (pointer);
@ -585,8 +585,8 @@ meta_wayland_pointer_set_current (MetaWaylandPointer *pointer,
{
if (pointer->current)
{
g_signal_handler_disconnect (pointer->current,
pointer->current_surface_destroyed_handler_id);
g_clear_signal_handler (&pointer->current_surface_destroyed_handler_id,
pointer->current);
pointer->current = NULL;
}
@ -917,9 +917,8 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
pointer->focus_client = NULL;
}
g_signal_handler_disconnect (pointer->focus_surface,
pointer->focus_surface_destroyed_handler_id);
pointer->focus_surface_destroyed_handler_id = 0;
g_clear_signal_handler (&pointer->focus_surface_destroyed_handler_id,
pointer->focus_surface);
pointer->focus_surface = NULL;
}
@ -1101,8 +1100,8 @@ meta_wayland_pointer_set_cursor_surface (MetaWaylandPointer *pointer,
if (prev_cursor_surface)
{
meta_wayland_surface_update_outputs (prev_cursor_surface);
g_signal_handler_disconnect (prev_cursor_surface,
pointer->cursor_surface_destroy_id);
g_clear_signal_handler (&pointer->cursor_surface_destroy_id,
prev_cursor_surface);
}
if (cursor_surface)

View File

@ -74,7 +74,7 @@ struct _MetaWaylandPointer
guint32 click_serial;
MetaWaylandSurface *cursor_surface;
guint cursor_surface_destroy_id;
gulong cursor_surface_destroy_id;
MetaWaylandPointerGrab *grab;
MetaWaylandPointerGrab default_grab;

View File

@ -444,11 +444,8 @@ pending_state_destroy (MetaWaylandPendingState *state)
g_clear_pointer (&state->opaque_region, cairo_region_destroy);
if (state->buffer)
{
g_signal_handler_disconnect (state->buffer,
state->buffer_destroy_handler_id);
state->buffer_destroy_handler_id = 0;
}
g_clear_signal_handler (&state->buffer_destroy_handler_id, state->buffer);
wl_list_for_each_safe (cb, next, &state->frame_callback_list, link)
wl_resource_destroy (cb->resource);
}
@ -467,18 +464,10 @@ merge_pending_state (MetaWaylandPendingState *from,
if (from->newly_attached)
{
if (to->buffer)
{
g_signal_handler_disconnect (to->buffer,
to->buffer_destroy_handler_id);
to->buffer_destroy_handler_id = 0;
}
g_clear_signal_handler (&to->buffer_destroy_handler_id, to->buffer);
if (from->buffer)
{
g_signal_handler_disconnect (from->buffer,
from->buffer_destroy_handler_id);
from->buffer_destroy_handler_id = 0;
}
g_clear_signal_handler (&from->buffer_destroy_handler_id, from->buffer);
to->newly_attached = TRUE;
to->buffer = from->buffer;
@ -906,8 +895,8 @@ wl_surface_attach (struct wl_client *client,
if (surface->pending->buffer)
{
g_signal_handler_disconnect (surface->pending->buffer,
surface->pending->buffer_destroy_handler_id);
g_clear_signal_handler (&surface->pending->buffer_destroy_handler_id,
surface->pending->buffer);
}
surface->pending->newly_attached = TRUE;

View File

@ -466,7 +466,7 @@ meta_wayland_tablet_tool_free (MetaWaylandTabletTool *tool)
wl_list_init (wl_resource_get_link (resource));
}
g_signal_handler_disconnect (tool->default_sprite, tool->prepare_at_signal_id);
g_clear_signal_handler (&tool->prepare_at_signal_id, tool->default_sprite);
g_object_unref (tool->default_sprite);
g_slice_free (MetaWaylandTabletTool, tool);

View File

@ -44,7 +44,7 @@ struct _MetaWaylandTabletTool
struct wl_listener cursor_surface_destroy_listener;
MetaCursorRenderer *cursor_renderer;
MetaCursorSpriteXcursor *default_sprite;
guint prepare_at_signal_id;
gulong prepare_at_signal_id;
MetaWaylandSurface *current;
guint32 pressed_buttons;

View File

@ -42,8 +42,7 @@ wp_viewport_destructor (struct wl_resource *resource)
if (!surface)
return;
g_signal_handler_disconnect (surface, surface->viewport.destroy_handler_id);
surface->viewport.destroy_handler_id = 0;
g_clear_signal_handler (&surface->viewport.destroy_handler_id, surface);
surface->pending->viewport_src_rect.size.width = -1;
surface->pending->viewport_dst_width = -1;

View File

@ -106,8 +106,8 @@ meta_wayland_xdg_exported_destroy (MetaWaylandXdgExported *exported)
meta_wayland_xdg_imported_destroy (imported);
}
g_signal_handler_disconnect (exported->surface,
exported->surface_unmapped_handler_id);
g_clear_signal_handler (&exported->surface_unmapped_handler_id,
exported->surface);
wl_resource_set_user_data (exported->resource, NULL);
g_hash_table_remove (foreign->exported_surfaces, exported->handle);
@ -287,8 +287,8 @@ xdg_imported_set_parent_of (struct wl_client *client,
}
if (imported->parent_of)
g_signal_handler_disconnect (imported->parent_of,
imported->parent_of_unmapped_handler_id);
g_clear_signal_handler (&imported->parent_of_unmapped_handler_id,
imported->parent_of);
imported->parent_of = surface;
@ -326,8 +326,8 @@ meta_wayland_xdg_imported_destroy (MetaWaylandXdgImported *imported)
{
MetaWindow *window;
g_signal_handler_disconnect (imported->parent_of,
imported->parent_of_unmapped_handler_id);
g_clear_signal_handler (&imported->parent_of_unmapped_handler_id,
imported->parent_of);
window = imported->parent_of->window;
if (window)

View File

@ -496,8 +496,8 @@ meta_wayland_xdg_popup_unmap (MetaWaylandXdgPopup *xdg_popup)
if (xdg_popup->parent_surface)
{
g_signal_handler_disconnect (xdg_popup->parent_surface,
xdg_popup->parent_surface_unmapped_handler_id);
g_clear_signal_handler (&xdg_popup->parent_surface_unmapped_handler_id,
xdg_popup->parent_surface);
xdg_popup->parent_surface = NULL;
}

View File

@ -95,21 +95,17 @@ meta_xwayland_keyboard_grab_end (MetaXwaylandKeyboardActiveGrab *active_grab)
if (!active_grab->surface)
return;
g_signal_handler_disconnect (active_grab->surface,
active_grab->surface_destroyed_handler);
g_clear_signal_handler (&active_grab->surface_destroyed_handler,
active_grab->surface);
g_signal_handler_disconnect (active_grab->surface,
active_grab->shortcuts_restored_handler);
g_clear_signal_handler (&active_grab->shortcuts_restored_handler,
active_grab->surface);
meta_wayland_surface_restore_shortcuts (active_grab->surface,
active_grab->seat);
if (active_grab->window_associate_handler)
{
g_signal_handler_disconnect (active_grab->surface->role,
active_grab->window_associate_handler);
active_grab->window_associate_handler = 0;
}
g_clear_signal_handler (&active_grab->window_associate_handler,
active_grab->surface->role);
active_grab->surface = NULL;
}
@ -243,12 +239,9 @@ meta_xwayland_keyboard_grab_activate (MetaXwaylandKeyboardActiveGrab *active_gra
if (meta_xwayland_grab_should_lock_focus (window))
meta_wayland_keyboard_start_grab (seat->keyboard, &active_grab->keyboard_grab);
}
if (active_grab->window_associate_handler)
{
g_signal_handler_disconnect (active_grab->surface->role,
active_grab->window_associate_handler);
active_grab->window_associate_handler = 0;
}
g_clear_signal_handler (&active_grab->window_associate_handler,
active_grab->surface->role);
}
static void

View File

@ -790,8 +790,8 @@ disconnect_pending_focus_window_signals (MetaWindow *window,
static void
meta_window_x11_delayed_focus_data_free (MetaWindowX11DelayedFocusData *data)
{
g_signal_handler_disconnect (data->window, data->unmanaged_id);
g_signal_handler_disconnect (data->window->display, data->focused_changed_id);
g_clear_signal_handler (&data->unmanaged_id, data->window);
g_clear_signal_handler (&data->focused_changed_id, data->window->display);
if (data->pending_focus_candidates)
{