cleanup: Use g_clear_handle_id() for g_source_remove()
It makes sure we do not forget to zero the id and lets us avoid zero checks before. We use it for all new code, lets clean up the existing code base. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/845
This commit is contained in:
parent
9132063b87
commit
c48330a986
@ -242,11 +242,7 @@ calendar_sources_finalize_source_data (CalendarSources *sources,
|
||||
g_hash_table_destroy (source_data->clients);
|
||||
source_data->clients = NULL;
|
||||
|
||||
if (source_data->timeout_id != 0)
|
||||
{
|
||||
g_source_remove (source_data->timeout_id);
|
||||
source_data->timeout_id = 0;
|
||||
}
|
||||
g_clear_handle_id (&source_data->timeout_id, g_source_remove);
|
||||
|
||||
source_data->loaded = FALSE;
|
||||
}
|
||||
@ -374,11 +370,7 @@ backend_died_cb (EClient *client, CalendarSourceData *source_data)
|
||||
g_warning ("The calendar backend for '%s' has crashed.", display_name);
|
||||
g_hash_table_remove (source_data->clients, source);
|
||||
|
||||
if (source_data->timeout_id != 0)
|
||||
{
|
||||
g_source_remove (source_data->timeout_id);
|
||||
source_data->timeout_id = 0;
|
||||
}
|
||||
g_clear_handle_id (&source_data->timeout_id, g_source_remove);
|
||||
|
||||
source_data->timeout_id = g_timeout_add_seconds (2, backend_restart,
|
||||
source_data);
|
||||
|
@ -792,8 +792,7 @@ app_free (App *app)
|
||||
g_clear_signal_handler (&app->sources_signal_id, app->sources);
|
||||
g_object_unref (app->sources);
|
||||
|
||||
if (app->changed_timeout_id != 0)
|
||||
g_source_remove (app->changed_timeout_id);
|
||||
g_clear_handle_id (&app->changed_timeout_id, g_source_remove);
|
||||
|
||||
g_free (app);
|
||||
}
|
||||
|
@ -60,11 +60,7 @@ ensure_autoquit_off (void)
|
||||
if (g_getenv ("HOTPLUG_SNIFFER_PERSIST") != NULL)
|
||||
return;
|
||||
|
||||
if (autoquit_id != 0)
|
||||
{
|
||||
g_source_remove (autoquit_id);
|
||||
autoquit_id = 0;
|
||||
}
|
||||
g_clear_handle_id (&autoquit_id, g_source_remove);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -483,11 +483,7 @@ shell_mime_sniffer_dispose (GObject *object)
|
||||
g_clear_object (&self->priv->cancellable);
|
||||
g_clear_object (&self->priv->task);
|
||||
|
||||
if (self->priv->watchdog_id != 0)
|
||||
{
|
||||
g_source_remove (self->priv->watchdog_id);
|
||||
self->priv->watchdog_id = 0;
|
||||
}
|
||||
g_clear_handle_id (&self->priv->watchdog_id, g_source_remove);
|
||||
|
||||
G_OBJECT_CLASS (shell_mime_sniffer_parent_class)->dispose (object);
|
||||
}
|
||||
|
@ -328,8 +328,7 @@ shell_app_usage_finalize (GObject *object)
|
||||
{
|
||||
ShellAppUsage *self = SHELL_APP_USAGE (object);
|
||||
|
||||
if (self->save_id > 0)
|
||||
g_source_remove (self->save_id);
|
||||
g_clear_handle_id (&self->save_id, g_source_remove);
|
||||
|
||||
g_object_unref (self->privacy_settings);
|
||||
|
||||
@ -743,11 +742,7 @@ update_enable_monitoring (ShellAppUsage *self)
|
||||
if (self->watched_app)
|
||||
g_object_unref (self->watched_app);
|
||||
self->watched_app = NULL;
|
||||
if (self->save_id)
|
||||
{
|
||||
g_source_remove (self->save_id);
|
||||
self->save_id = 0;
|
||||
}
|
||||
g_clear_handle_id (&self->save_id, g_source_remove);
|
||||
}
|
||||
|
||||
self->enable_monitoring = enable;
|
||||
|
@ -84,8 +84,7 @@ on_timeout (gpointer data)
|
||||
static void
|
||||
establish_timeout (void)
|
||||
{
|
||||
if (timeout_id != 0)
|
||||
g_source_remove (timeout_id);
|
||||
g_clear_handle_id (&timeout_id, g_source_remove);
|
||||
|
||||
timeout_id = g_timeout_add (opt_idle_timeout * 1000, on_timeout, NULL);
|
||||
g_source_set_name_by_id (timeout_id, "[gnome-shell] on_timeout");
|
||||
|
@ -218,8 +218,7 @@ shell_perf_log_set_enabled (ShellPerfLog *perf_log,
|
||||
}
|
||||
else
|
||||
{
|
||||
g_source_remove (perf_log->statistics_timeout_id);
|
||||
perf_log->statistics_timeout_id = 0;
|
||||
g_clear_handle_id (&perf_log->statistics_timeout_id, g_source_remove);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -241,8 +241,7 @@ shell_recorder_src_finalize (GObject *object)
|
||||
{
|
||||
ShellRecorderSrc *src = SHELL_RECORDER_SRC (object);
|
||||
|
||||
if (src->memory_used_update_idle)
|
||||
g_source_remove (src->memory_used_update_idle);
|
||||
g_clear_handle_id (&src->memory_used_update_idle, g_source_remove);
|
||||
|
||||
shell_recorder_src_set_caps (src, NULL);
|
||||
g_queue_free_full (src->queue, (GDestroyNotify) gst_buffer_unref);
|
||||
|
@ -220,8 +220,7 @@ shell_recorder_finalize (GObject *object)
|
||||
{
|
||||
ShellRecorder *recorder = SHELL_RECORDER (object);
|
||||
|
||||
if (recorder->update_memory_used_timeout)
|
||||
g_source_remove (recorder->update_memory_used_timeout);
|
||||
g_clear_handle_id (&recorder->update_memory_used_timeout, g_source_remove);
|
||||
|
||||
if (recorder->cursor_image)
|
||||
cairo_surface_destroy (recorder->cursor_image);
|
||||
@ -298,11 +297,7 @@ recorder_add_redraw_timeout (ShellRecorder *recorder)
|
||||
static void
|
||||
recorder_remove_redraw_timeout (ShellRecorder *recorder)
|
||||
{
|
||||
if (recorder->redraw_timeout != 0)
|
||||
{
|
||||
g_source_remove (recorder->redraw_timeout);
|
||||
recorder->redraw_timeout = 0;
|
||||
}
|
||||
g_clear_handle_id (&recorder->redraw_timeout, g_source_remove);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -608,11 +603,7 @@ recorder_add_update_pointer_timeout (ShellRecorder *recorder)
|
||||
static void
|
||||
recorder_remove_update_pointer_timeout (ShellRecorder *recorder)
|
||||
{
|
||||
if (recorder->update_pointer_timeout)
|
||||
{
|
||||
g_source_remove (recorder->update_pointer_timeout);
|
||||
recorder->update_pointer_timeout = 0;
|
||||
}
|
||||
g_clear_handle_id (&recorder->update_pointer_timeout, g_source_remove);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -648,11 +639,7 @@ recorder_disconnect_stage_callbacks (ShellRecorder *recorder)
|
||||
* us the events is close to free in any case.
|
||||
*/
|
||||
|
||||
if (recorder->redraw_idle)
|
||||
{
|
||||
g_source_remove (recorder->redraw_idle);
|
||||
recorder->redraw_idle = 0;
|
||||
}
|
||||
g_clear_handle_id (&recorder->redraw_idle, g_source_remove);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -818,11 +818,7 @@ trough_button_release_event_cb (ClutterActor *actor,
|
||||
if (event->button != 1)
|
||||
return FALSE;
|
||||
|
||||
if (priv->paging_source_id)
|
||||
{
|
||||
g_source_remove (priv->paging_source_id);
|
||||
priv->paging_source_id = 0;
|
||||
}
|
||||
g_clear_handle_id (&priv->paging_source_id, g_source_remove);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -836,8 +832,7 @@ trough_leave_event_cb (ClutterActor *actor,
|
||||
|
||||
if (priv->paging_source_id)
|
||||
{
|
||||
g_source_remove (priv->paging_source_id);
|
||||
priv->paging_source_id = 0;
|
||||
g_clear_handle_id (&priv->paging_source_id, g_source_remove);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user