cleanup: Use g_clear_signal_handler() where possible
`g_clear_signal_handler()` is usually cleaner and saver than `g_signal_handler_disconnect()`. We use it new code, lets also adopt the existing one. See also https://gitlab.gnome.org/GNOME/mutter/merge_requests/868 and https://gitlab.gnome.org/GNOME/mutter/merge_requests/940 https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/842
This commit is contained in:
parent
e7b9bd75d8
commit
135d178d08
@ -112,7 +112,7 @@ static CalendarSources *calendar_sources_singleton = NULL;
|
||||
static void
|
||||
client_data_free (ClientData *data)
|
||||
{
|
||||
g_signal_handler_disconnect (data->client, data->backend_died_id);
|
||||
g_clear_signal_handler (&data->backend_died_id, data->client);
|
||||
g_object_unref (data->client);
|
||||
g_slice_free (ClientData, data);
|
||||
}
|
||||
@ -259,12 +259,12 @@ calendar_sources_finalize (GObject *object)
|
||||
|
||||
if (sources->priv->registry)
|
||||
{
|
||||
g_signal_handler_disconnect (sources->priv->registry,
|
||||
sources->priv->source_added_id);
|
||||
g_signal_handler_disconnect (sources->priv->registry,
|
||||
sources->priv->source_changed_id);
|
||||
g_signal_handler_disconnect (sources->priv->registry,
|
||||
sources->priv->source_removed_id);
|
||||
g_clear_signal_handler (&sources->priv->source_added_id,
|
||||
sources->priv->registry);
|
||||
g_clear_signal_handler (&sources->priv->source_changed_id,
|
||||
sources->priv->registry);
|
||||
g_clear_signal_handler (&sources->priv->source_removed_id,
|
||||
sources->priv->registry);
|
||||
g_object_unref (sources->priv->registry);
|
||||
}
|
||||
sources->priv->registry = NULL;
|
||||
|
@ -789,8 +789,7 @@ app_free (App *app)
|
||||
g_hash_table_unref (app->appointments);
|
||||
|
||||
g_object_unref (app->connection);
|
||||
g_signal_handler_disconnect (app->sources,
|
||||
app->sources_signal_id);
|
||||
g_clear_signal_handler (&app->sources_signal_id, app->sources);
|
||||
g_object_unref (app->sources);
|
||||
|
||||
if (app->changed_timeout_id != 0)
|
||||
|
@ -540,7 +540,7 @@ gtk_action_muxer_free_group (gpointer data)
|
||||
|
||||
/* 'for loop' or 'four loop'? */
|
||||
for (i = 0; i < 4; i++)
|
||||
g_signal_handler_disconnect (group->group, group->handler_ids[i]);
|
||||
g_clear_signal_handler (&group->handler_ids[i], group->group);
|
||||
|
||||
g_object_unref (group->group);
|
||||
g_free (group->prefix);
|
||||
|
@ -35,7 +35,7 @@ typedef struct {
|
||||
guint refcount;
|
||||
|
||||
/* Signal connection to dirty window sort list on workspace changes */
|
||||
guint workspace_switch_id;
|
||||
gulong workspace_switch_id;
|
||||
|
||||
GSList *windows;
|
||||
|
||||
@ -1445,7 +1445,7 @@ unref_running_state (ShellAppRunningState *state)
|
||||
if (state->refcount > 0)
|
||||
return;
|
||||
|
||||
g_signal_handler_disconnect (workspace_manager, state->workspace_switch_id);
|
||||
g_clear_signal_handler (&state->workspace_switch_id, workspace_manager);
|
||||
|
||||
g_clear_object (&state->application_proxy);
|
||||
|
||||
|
@ -23,9 +23,9 @@ struct _ShellGtkEmbedPrivate
|
||||
ShellEmbeddedWindow *window;
|
||||
|
||||
ClutterActor *window_actor;
|
||||
guint window_actor_destroyed_handler;
|
||||
gulong window_actor_destroyed_handler;
|
||||
|
||||
guint window_created_handler;
|
||||
gulong window_created_handler;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE (ShellGtkEmbed, shell_gtk_embed, CLUTTER_TYPE_CLONE);
|
||||
@ -47,9 +47,8 @@ shell_gtk_embed_remove_window_actor (ShellGtkEmbed *embed)
|
||||
|
||||
if (priv->window_actor)
|
||||
{
|
||||
g_signal_handler_disconnect (priv->window_actor,
|
||||
priv->window_actor_destroyed_handler);
|
||||
priv->window_actor_destroyed_handler = 0;
|
||||
g_clear_signal_handler (&priv->window_actor_destroyed_handler,
|
||||
priv->window_actor);
|
||||
|
||||
g_object_unref (priv->window_actor);
|
||||
priv->window_actor = NULL;
|
||||
@ -116,9 +115,8 @@ shell_gtk_embed_window_created_cb (MetaDisplay *display,
|
||||
|
||||
/* Now that we've found the window we don't need to listen for
|
||||
new windows anymore */
|
||||
g_signal_handler_disconnect (display,
|
||||
priv->window_created_handler);
|
||||
priv->window_created_handler = 0;
|
||||
g_clear_signal_handler (&priv->window_created_handler,
|
||||
display);
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,12 +146,7 @@ shell_gtk_embed_set_window (ShellGtkEmbed *embed,
|
||||
|
||||
if (priv->window)
|
||||
{
|
||||
if (priv->window_created_handler)
|
||||
{
|
||||
g_signal_handler_disconnect (display,
|
||||
priv->window_created_handler);
|
||||
priv->window_created_handler = 0;
|
||||
}
|
||||
g_clear_signal_handler (&priv->window_created_handler, display);
|
||||
|
||||
shell_gtk_embed_remove_window_actor (embed);
|
||||
|
||||
|
@ -623,7 +623,7 @@ transition_closure_free (gpointer data)
|
||||
clos = data;
|
||||
timeline = CLUTTER_TIMELINE (clos->transition);
|
||||
|
||||
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);
|
||||
|
@ -50,7 +50,7 @@ struct _StIconPrivate
|
||||
{
|
||||
ClutterActor *icon_texture;
|
||||
ClutterActor *pending_texture;
|
||||
guint opacity_handler_id;
|
||||
gulong opacity_handler_id;
|
||||
|
||||
GIcon *gicon;
|
||||
gint prop_icon_size; /* icon size set as property */
|
||||
@ -369,8 +369,7 @@ opacity_changed_cb (GObject *object,
|
||||
StIcon *icon = user_data;
|
||||
StIconPrivate *priv = icon->priv;
|
||||
|
||||
g_signal_handler_disconnect (priv->pending_texture, priv->opacity_handler_id);
|
||||
priv->opacity_handler_id = 0;
|
||||
g_clear_signal_handler (&priv->opacity_handler_id, priv->pending_texture);
|
||||
|
||||
st_icon_finish_update (icon);
|
||||
}
|
||||
|
@ -707,7 +707,7 @@ typedef struct {
|
||||
ClutterActor *actor;
|
||||
gint size;
|
||||
GObject *source;
|
||||
guint notify_signal_id;
|
||||
gulong notify_signal_id;
|
||||
gboolean weakref_active;
|
||||
} StTextureCachePropertyBind;
|
||||
|
||||
@ -772,7 +772,7 @@ st_texture_cache_bind_weak_notify (gpointer data,
|
||||
{
|
||||
StTextureCachePropertyBind *bind = data;
|
||||
bind->weakref_active = FALSE;
|
||||
g_signal_handler_disconnect (bind->source, bind->notify_signal_id);
|
||||
g_clear_signal_handler (&bind->notify_signal_id, bind->source);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -54,8 +54,8 @@ struct _StThemeNodeTransitionPrivate {
|
||||
|
||||
ClutterTimeline *timeline;
|
||||
|
||||
guint timeline_completed_id;
|
||||
guint timeline_new_frame_id;
|
||||
gulong timeline_completed_id;
|
||||
gulong timeline_new_frame_id;
|
||||
|
||||
ClutterActorBox last_allocation;
|
||||
ClutterActorBox offscreen_box;
|
||||
@ -410,12 +410,8 @@ st_theme_node_transition_dispose (GObject *object)
|
||||
|
||||
if (priv->timeline)
|
||||
{
|
||||
if (priv->timeline_completed_id != 0)
|
||||
g_signal_handler_disconnect (priv->timeline,
|
||||
priv->timeline_completed_id);
|
||||
if (priv->timeline_new_frame_id != 0)
|
||||
g_signal_handler_disconnect (priv->timeline,
|
||||
priv->timeline_new_frame_id);
|
||||
g_clear_signal_handler (&priv->timeline_completed_id, priv->timeline);
|
||||
g_clear_signal_handler (&priv->timeline_new_frame_id, priv->timeline);
|
||||
|
||||
g_clear_object (&priv->timeline);
|
||||
}
|
||||
|
@ -308,11 +308,8 @@ st_widget_dispose (GObject *gobject)
|
||||
|
||||
g_clear_pointer (&priv->label_actor, g_object_unref);
|
||||
|
||||
if (priv->texture_file_changed_id != 0)
|
||||
{
|
||||
g_signal_handler_disconnect (st_texture_cache_get_default (), priv->texture_file_changed_id);
|
||||
priv->texture_file_changed_id = 0;
|
||||
}
|
||||
g_clear_signal_handler (&priv->texture_file_changed_id,
|
||||
st_texture_cache_get_default ());
|
||||
|
||||
g_clear_object (&priv->first_visible_child);
|
||||
g_clear_object (&priv->last_visible_child);
|
||||
|
Loading…
Reference in New Issue
Block a user