[mutter] cleanup: Use g_clear_handle_id() for g_source_remove()
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] cleanup: Use g_clear_handle_id() for g_source_remove()
- Date: Fri, 22 Nov 2019 01:34:49 +0000 (UTC)
commit 8e172aeecb0540acb0638c2a7c47e8c537085050
Author: Robert Mader <robert mader posteo de>
Date: Fri Nov 22 00:25:30 2019 +0100
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/mutter/merge_requests/947
clutter/clutter/cally/cally-actor.c | 6 +--
clutter/clutter/cally/cally-text.c | 6 +--
clutter/clutter/clutter-click-action.c | 21 ++--------
clutter/clutter/clutter-input-pointer-a11y.c | 7 ++--
clutter/clutter/clutter-text.c | 9 +----
cogl/tests/conform/test-materials.c | 2 +-
cogl/tests/conform/test-multitexture.c | 2 +-
cogl/tests/conform/test-readpixels.c | 2 +-
cogl/tests/conform/test-texture-mipmaps.c | 2 +-
cogl/tests/conform/test-texture-pixmap-x11.c | 2 +-
cogl/tests/conform/test-vertex-buffer-contiguous.c | 2 +-
cogl/tests/conform/test-vertex-buffer-interleved.c | 2 +-
cogl/tests/conform/test-viewport.c | 2 +-
src/backends/meta-backend.c | 3 +-
src/backends/meta-idle-monitor.c | 12 +-----
src/backends/meta-monitor-manager.c | 3 +-
src/backends/native/meta-cursor-renderer-native.c | 9 +----
src/backends/native/meta-input-device-native.c | 21 ++--------
src/backends/native/meta-renderer-native.c | 3 +-
src/backends/native/meta-seat-native.c | 3 +-
src/backends/x11/meta-input-device-x11.c | 3 +-
src/backends/x11/meta-stage-x11.c | 4 +-
src/compositor/meta-shaped-texture.c | 6 +--
src/compositor/meta-window-actor-x11.c | 3 +-
src/core/display.c | 47 +++++-----------------
src/core/edge-resistance.c | 26 +++++-------
src/core/meta-close-dialog-default.c | 9 +----
src/core/meta-gesture-tracker.c | 9 +----
src/core/startup-notification.c | 11 ++---
src/core/util.c | 6 +--
src/core/window.c | 18 ++-------
src/tests/clutter/conform/timeline.c | 2 +-
.../clutter/interactive/test-cogl-shader-glsl.c | 6 +--
src/wayland/meta-xwayland.c | 6 +--
src/x11/meta-x11-display.c | 6 +--
src/x11/session.c | 2 +-
src/x11/window-x11.c | 3 +-
37 files changed, 75 insertions(+), 211 deletions(-)
---
diff --git a/clutter/clutter/cally/cally-actor.c b/clutter/clutter/cally/cally-actor.c
index 07eaea67d..c92b576e1 100644
--- a/clutter/clutter/cally/cally-actor.c
+++ b/clutter/clutter/cally/cally-actor.c
@@ -310,11 +310,7 @@ cally_actor_finalize (GObject *obj)
_cally_actor_clean_action_list (cally_actor);
- if (priv->action_idle_handler)
- {
- g_source_remove (priv->action_idle_handler);
- priv->action_idle_handler = 0;
- }
+ g_clear_handle_id (&priv->action_idle_handler, g_source_remove);
if (priv->action_queue)
{
diff --git a/clutter/clutter/cally/cally-text.c b/clutter/clutter/cally/cally-text.c
index cbdec8496..2b34f098c 100644
--- a/clutter/clutter/cally/cally-text.c
+++ b/clutter/clutter/cally/cally-text.c
@@ -247,11 +247,7 @@ cally_text_finalize (GObject *obj)
/* g_object_unref (cally_text->priv->textutil); */
/* cally_text->priv->textutil = NULL; */
- if (cally_text->priv->insert_idle_handler)
- {
- g_source_remove (cally_text->priv->insert_idle_handler);
- cally_text->priv->insert_idle_handler = 0;
- }
+ g_clear_handle_id (&cally_text->priv->insert_idle_handler, g_source_remove);
G_OBJECT_CLASS (cally_text_parent_class)->finalize (obj);
}
diff --git a/clutter/clutter/clutter-click-action.c b/clutter/clutter/clutter-click-action.c
index 746586a45..6b523b033 100644
--- a/clutter/clutter/clutter-click-action.c
+++ b/clutter/clutter/clutter-click-action.c
@@ -257,8 +257,7 @@ click_action_cancel_long_press (ClutterClickAction *action)
actor = clutter_actor_meta_get_actor (CLUTTER_ACTOR_META (action));
- g_source_remove (priv->long_press_id);
- priv->long_press_id = 0;
+ g_clear_handle_id (&priv->long_press_id, g_source_remove);
g_signal_emit (action, click_signals[LONG_PRESS], 0,
actor,
@@ -373,11 +372,7 @@ on_captured_event (ClutterActor *stage,
/* disconnect the capture */
g_clear_signal_handler (&priv->capture_id, priv->stage);
- if (priv->long_press_id != 0)
- {
- g_source_remove (priv->long_press_id);
- priv->long_press_id = 0;
- }
+ g_clear_handle_id (&priv->long_press_id, g_source_remove);
if (!clutter_actor_contains (actor, clutter_event_get_source (event)))
return CLUTTER_EVENT_PROPAGATE;
@@ -459,11 +454,7 @@ clutter_click_action_set_actor (ClutterActorMeta *meta,
priv->stage = NULL;
}
- if (priv->long_press_id != 0)
- {
- g_source_remove (priv->long_press_id);
- priv->long_press_id = 0;
- }
+ g_clear_handle_id (&priv->long_press_id, g_source_remove);
click_action_set_pressed (action, FALSE);
click_action_set_held (action, FALSE);
@@ -542,11 +533,7 @@ clutter_click_action_dispose (GObject *gobject)
g_clear_signal_handler (&priv->capture_id, priv->stage);
- if (priv->long_press_id)
- {
- g_source_remove (priv->long_press_id);
- priv->long_press_id = 0;
- }
+ g_clear_handle_id (&priv->long_press_id, g_source_remove);
G_OBJECT_CLASS (clutter_click_action_parent_class)->dispose (gobject);
}
diff --git a/clutter/clutter/clutter-input-pointer-a11y.c b/clutter/clutter/clutter-input-pointer-a11y.c
index f5bc86dca..e790fdad3 100644
--- a/clutter/clutter/clutter-input-pointer-a11y.c
+++ b/clutter/clutter/clutter-input-pointer-a11y.c
@@ -197,8 +197,8 @@ stop_secondary_click_timeout (ClutterInputDevice *device)
{
if (device->ptr_a11y_data->secondary_click_timer)
{
- g_source_remove (device->ptr_a11y_data->secondary_click_timer);
- device->ptr_a11y_data->secondary_click_timer = 0;
+ g_clear_handle_id (&device->ptr_a11y_data->secondary_click_timer,
+ g_source_remove);
g_signal_emit_by_name (device->device_manager,
"ptr-a11y-timeout-stopped",
@@ -511,8 +511,7 @@ stop_dwell_timeout (ClutterInputDevice *device)
{
if (device->ptr_a11y_data->dwell_timer)
{
- g_source_remove (device->ptr_a11y_data->dwell_timer);
- device->ptr_a11y_data->dwell_timer = 0;
+ g_clear_handle_id (&device->ptr_a11y_data->dwell_timer, g_source_remove);
device->ptr_a11y_data->dwell_gesture_started = FALSE;
g_signal_emit_by_name (device->device_manager,
diff --git a/clutter/clutter/clutter-text.c b/clutter/clutter/clutter-text.c
index 7dcb67dae..b4dea0f6b 100644
--- a/clutter/clutter/clutter-text.c
+++ b/clutter/clutter/clutter-text.c
@@ -1763,11 +1763,7 @@ clutter_text_dispose (GObject *gobject)
g_clear_signal_handler (&priv->settings_changed_id,
clutter_get_default_backend ());
- if (priv->password_hint_id)
- {
- g_source_remove (priv->password_hint_id);
- priv->password_hint_id = 0;
- }
+ g_clear_handle_id (&priv->password_hint_id, g_source_remove);
clutter_text_set_buffer (self, NULL);
@@ -2450,8 +2446,7 @@ clutter_text_key_press (ClutterActor *actor,
if (priv->show_password_hint)
{
- if (priv->password_hint_id != 0)
- g_source_remove (priv->password_hint_id);
+ g_clear_handle_id (&priv->password_hint_id, g_source_remove);
priv->password_hint_visible = TRUE;
priv->password_hint_id =
diff --git a/cogl/tests/conform/test-materials.c b/cogl/tests/conform/test-materials.c
index 2f1edf06c..b6d66ebf9 100644
--- a/cogl/tests/conform/test-materials.c
+++ b/cogl/tests/conform/test-materials.c
@@ -245,7 +245,7 @@ test_materials (TestUtilsGTestFixture *fixture,
clutter_main ();
- g_source_remove (idle_source);
+ g_clear_handle_id (&idle_source, g_source_remove);
if (cogl_test_verbose ())
g_print ("OK\n");
diff --git a/cogl/tests/conform/test-multitexture.c b/cogl/tests/conform/test-multitexture.c
index 0968527eb..d87a88d2c 100644
--- a/cogl/tests/conform/test-multitexture.c
+++ b/cogl/tests/conform/test-multitexture.c
@@ -199,7 +199,7 @@ test_multitexture (TestUtilsGTestFixture *fixture,
clutter_main ();
- g_source_remove (idle_source);
+ g_clear_handle_id (&idle_source, g_source_remove);
if (cogl_test_verbose ())
g_print ("OK\n");
diff --git a/cogl/tests/conform/test-readpixels.c b/cogl/tests/conform/test-readpixels.c
index 3c7c512db..42951dad5 100644
--- a/cogl/tests/conform/test-readpixels.c
+++ b/cogl/tests/conform/test-readpixels.c
@@ -165,7 +165,7 @@ test_readpixels (TestUtilsGTestFixture *fixture,
clutter_actor_show (stage);
clutter_main ();
- g_source_remove (idle_source);
+ g_clear_handle_id (&idle_source, g_source_remove);
/* Remove all of the actors from the stage */
clutter_actor_remove_all_children (stage);
diff --git a/cogl/tests/conform/test-texture-mipmaps.c b/cogl/tests/conform/test-texture-mipmaps.c
index ab239f3d7..d4edbb1bd 100644
--- a/cogl/tests/conform/test-texture-mipmaps.c
+++ b/cogl/tests/conform/test-texture-mipmaps.c
@@ -129,7 +129,7 @@ test_texture_mipmaps (TestUtilsGTestFixture *fixture,
clutter_main ();
- g_source_remove (idle_source);
+ g_clear_handle_id (&idle_source, g_source_remove);
if (cogl_test_verbose ())
g_print ("OK\n");
diff --git a/cogl/tests/conform/test-texture-pixmap-x11.c b/cogl/tests/conform/test-texture-pixmap-x11.c
index 3aef03282..4424a60db 100644
--- a/cogl/tests/conform/test-texture-pixmap-x11.c
+++ b/cogl/tests/conform/test-texture-pixmap-x11.c
@@ -228,7 +228,7 @@ test_texture_pixmap_x11 (TestUtilsGTestFixture *fixture,
g_clear_signal_handler (&paint_handler, state.stage);
- g_source_remove (idle_handler);
+ g_clear_handle_id (&idle_handler, g_source_remove);
XFreePixmap (state.display, state.pixmap);
diff --git a/cogl/tests/conform/test-vertex-buffer-contiguous.c
b/cogl/tests/conform/test-vertex-buffer-contiguous.c
index 2afbf4bde..2bc89fa1c 100644
--- a/cogl/tests/conform/test-vertex-buffer-contiguous.c
+++ b/cogl/tests/conform/test-vertex-buffer-contiguous.c
@@ -249,7 +249,7 @@ test_vertex_buffer_contiguous (TestUtilsGTestFixture *fixture,
cogl_object_unref (state.material);
cogl_object_unref (state.texture);
- g_source_remove (idle_source);
+ g_clear_handle_id (&idle_source, g_source_remove);
if (cogl_test_verbose ())
g_print ("OK\n");
diff --git a/cogl/tests/conform/test-vertex-buffer-interleved.c
b/cogl/tests/conform/test-vertex-buffer-interleved.c
index fd1060ef9..c1696e97a 100644
--- a/cogl/tests/conform/test-vertex-buffer-interleved.c
+++ b/cogl/tests/conform/test-vertex-buffer-interleved.c
@@ -154,7 +154,7 @@ test_vertex_buffer_interleved (TestUtilsGTestFixture *fixture,
cogl_object_unref (state.buffer);
- g_source_remove (idle_source);
+ g_clear_handle_id (&idle_source, g_source_remove);
if (cogl_test_verbose ())
g_print ("OK\n");
diff --git a/cogl/tests/conform/test-viewport.c b/cogl/tests/conform/test-viewport.c
index 308d740cd..9d9af0e02 100644
--- a/cogl/tests/conform/test-viewport.c
+++ b/cogl/tests/conform/test-viewport.c
@@ -403,7 +403,7 @@ test_viewport (TestUtilsGTestFixture *fixture,
clutter_actor_show (stage);
clutter_main ();
- g_source_remove (idle_source);
+ g_clear_handle_id (&idle_source, g_source_remove);
/* Remove all of the actors from the stage */
clutter_actor_remove_all_children (stage);
diff --git a/src/backends/meta-backend.c b/src/backends/meta-backend.c
index 3b048fa2d..12db4b686 100644
--- a/src/backends/meta-backend.c
+++ b/src/backends/meta-backend.c
@@ -208,8 +208,7 @@ meta_backend_finalize (GObject *object)
g_clear_object (&priv->system_bus);
g_clear_object (&priv->upower_proxy);
- if (priv->device_update_idle_id)
- g_source_remove (priv->device_update_idle_id);
+ g_clear_handle_id (&priv->device_update_idle_id, g_source_remove);
g_hash_table_destroy (priv->device_monitors);
diff --git a/src/backends/meta-idle-monitor.c b/src/backends/meta-idle-monitor.c
index 2ff1602e7..4304db142 100644
--- a/src/backends/meta-idle-monitor.c
+++ b/src/backends/meta-idle-monitor.c
@@ -64,11 +64,7 @@ meta_idle_monitor_watch_fire (MetaIdleMonitorWatch *watch)
monitor = watch->monitor;
g_object_ref (monitor);
- if (watch->idle_source_id)
- {
- g_source_remove (watch->idle_source_id);
- watch->idle_source_id = 0;
- }
+ g_clear_handle_id (&watch->idle_source_id, g_source_remove);
id = watch->id;
is_user_active_watch = (watch->timeout_msec == 0);
@@ -161,11 +157,7 @@ free_watch (gpointer data)
g_object_ref (monitor);
- if (watch->idle_source_id)
- {
- g_source_remove (watch->idle_source_id);
- watch->idle_source_id = 0;
- }
+ g_clear_handle_id (&watch->idle_source_id, g_source_remove);
if (watch->notify != NULL)
watch->notify (watch->user_data);
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index b6368e83a..b773d436f 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -1232,8 +1232,7 @@ save_config_timeout (gpointer user_data)
static void
cancel_persistent_confirmation (MetaMonitorManager *manager)
{
- g_source_remove (manager->persistent_timeout_id);
- manager->persistent_timeout_id = 0;
+ g_clear_handle_id (&manager->persistent_timeout_id, g_source_remove);
}
static void
diff --git a/src/backends/native/meta-cursor-renderer-native.c
b/src/backends/native/meta-cursor-renderer-native.c
index 8c478c818..687fa9925 100644
--- a/src/backends/native/meta-cursor-renderer-native.c
+++ b/src/backends/native/meta-cursor-renderer-native.c
@@ -166,8 +166,7 @@ meta_cursor_renderer_native_finalize (GObject *object)
MetaCursorRendererNativePrivate *priv =
meta_cursor_renderer_native_get_instance_private (renderer);
- if (priv->animation_timeout_id)
- g_source_remove (priv->animation_timeout_id);
+ g_clear_handle_id (&priv->animation_timeout_id, g_source_remove);
G_OBJECT_CLASS (meta_cursor_renderer_native_parent_class)->finalize (object);
}
@@ -658,11 +657,7 @@ maybe_schedule_cursor_sprite_animation_frame (MetaCursorRendererNative *native,
if (!cursor_change && priv->animation_timeout_id)
return;
- if (priv->animation_timeout_id)
- {
- g_source_remove (priv->animation_timeout_id);
- priv->animation_timeout_id = 0;
- }
+ g_clear_handle_id (&priv->animation_timeout_id, g_source_remove);
if (cursor_sprite && meta_cursor_sprite_is_animated (cursor_sprite))
{
diff --git a/src/backends/native/meta-input-device-native.c b/src/backends/native/meta-input-device-native.c
index 4fd15a34a..312d715c0 100644
--- a/src/backends/native/meta-input-device-native.c
+++ b/src/backends/native/meta-input-device-native.c
@@ -235,8 +235,7 @@ meta_input_device_native_free_pending_slow_key (gpointer data)
SlowKeysEventPending *slow_keys_event = data;
clutter_event_free (slow_keys_event->event);
- if (slow_keys_event->timer)
- g_source_remove (slow_keys_event->timer);
+ g_clear_handle_id (&slow_keys_event->timer, g_source_remove);
g_free (slow_keys_event);
}
@@ -381,11 +380,7 @@ start_bounce_keys (ClutterEvent *event,
static void
stop_bounce_keys (MetaInputDeviceNative *device)
{
- if (device->debounce_timer)
- {
- g_source_remove (device->debounce_timer);
- device->debounce_timer = 0;
- }
+ g_clear_handle_id (&device->debounce_timer, g_source_remove);
}
static void
@@ -656,11 +651,7 @@ start_toggle_slowkeys (MetaInputDeviceNative *device)
static void
stop_toggle_slowkeys (MetaInputDeviceNative *device)
{
- if (device->toggle_slowkeys_timer)
- {
- g_source_remove (device->toggle_slowkeys_timer);
- device->toggle_slowkeys_timer = 0;
- }
+ g_clear_handle_id (&device->toggle_slowkeys_timer, g_source_remove);
}
static void
@@ -988,11 +979,7 @@ stop_mousekeys_move (MetaInputDeviceNative *device)
device->mousekeys_first_motion_time = 0;
device->mousekeys_last_motion_time = 0;
- if (device->move_mousekeys_timer)
- {
- g_source_remove (device->move_mousekeys_timer);
- device->move_mousekeys_timer = 0;
- }
+ g_clear_handle_id (&device->move_mousekeys_timer, g_source_remove);
}
static void
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index 84b6a7323..e6376493e 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -4143,7 +4143,8 @@ meta_renderer_native_finalize (GObject *object)
{
g_list_free_full (renderer_native->power_save_page_flip_onscreens,
(GDestroyNotify) cogl_object_unref);
- g_source_remove (renderer_native->power_save_page_flip_source_id);
+ g_clear_handle_id (&renderer_native->power_save_page_flip_source_id,
+ g_source_remove);
}
g_hash_table_destroy (renderer_native->gpu_datas);
diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c
index a14509bd3..75854e69a 100644
--- a/src/backends/native/meta-seat-native.c
+++ b/src/backends/native/meta-seat-native.c
@@ -207,8 +207,7 @@ meta_seat_native_clear_repeat_timer (MetaSeatNative *seat)
{
if (seat->repeat_timer)
{
- g_source_remove (seat->repeat_timer);
- seat->repeat_timer = 0;
+ g_clear_handle_id (&seat->repeat_timer, g_source_remove);
g_clear_object (&seat->repeat_device);
}
}
diff --git a/src/backends/x11/meta-input-device-x11.c b/src/backends/x11/meta-input-device-x11.c
index c04c1404e..4b1eeddf9 100644
--- a/src/backends/x11/meta-input-device-x11.c
+++ b/src/backends/x11/meta-input-device-x11.c
@@ -107,8 +107,7 @@ meta_input_device_x11_finalize (GObject *object)
if (device_xi2->group_modes)
g_array_unref (device_xi2->group_modes);
- if (device_xi2->inhibit_pointer_query_timer)
- g_source_remove (device_xi2->inhibit_pointer_query_timer);
+ g_clear_handle_id (&device_xi2->inhibit_pointer_query_timer, g_source_remove);
#endif
G_OBJECT_CLASS (meta_input_device_x11_parent_class)->finalize (object);
diff --git a/src/backends/x11/meta-stage-x11.c b/src/backends/x11/meta-stage-x11.c
index 0f39bf990..6a154709c 100644
--- a/src/backends/x11/meta-stage-x11.c
+++ b/src/backends/x11/meta-stage-x11.c
@@ -799,8 +799,8 @@ meta_stage_x11_translate_event (MetaStageX11 *stage_x11,
* fallback to redrawing the full stage until the cooling
* off period is over.
*/
- if (stage_x11->clipped_redraws_cool_off)
- g_source_remove (stage_x11->clipped_redraws_cool_off);
+ g_clear_handle_id (&stage_x11->clipped_redraws_cool_off,
+ g_source_remove);
stage_x11->clipped_redraws_cool_off =
clutter_threads_add_timeout (1000,
diff --git a/src/compositor/meta-shaped-texture.c b/src/compositor/meta-shaped-texture.c
index 401aaadf7..5e1021f8c 100644
--- a/src/compositor/meta-shaped-texture.c
+++ b/src/compositor/meta-shaped-texture.c
@@ -228,11 +228,7 @@ meta_shaped_texture_dispose (GObject *object)
{
MetaShapedTexture *stex = (MetaShapedTexture *) object;
- if (stex->remipmap_timeout_id)
- {
- g_source_remove (stex->remipmap_timeout_id);
- stex->remipmap_timeout_id = 0;
- }
+ g_clear_handle_id (&stex->remipmap_timeout_id, g_source_remove);
if (stex->paint_tower)
meta_texture_tower_free (stex->paint_tower);
diff --git a/src/compositor/meta-window-actor-x11.c b/src/compositor/meta-window-actor-x11.c
index 8bf65351f..2800ffb04 100644
--- a/src/compositor/meta-window-actor-x11.c
+++ b/src/compositor/meta-window-actor-x11.c
@@ -144,8 +144,7 @@ remove_frame_messages_timer (MetaWindowActorX11 *actor_x11)
{
g_assert (actor_x11->send_frame_messages_timer != 0);
- g_source_remove (actor_x11->send_frame_messages_timer);
- actor_x11->send_frame_messages_timer = 0;
+ g_clear_handle_id (&actor_x11->send_frame_messages_timer, g_source_remove);
}
static void
diff --git a/src/core/display.c b/src/core/display.c
index b18f5a558..64da04d5d 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -522,8 +522,7 @@ static void
ping_data_free (MetaPingData *ping_data)
{
/* Remove the timeout */
- if (ping_data->ping_timeout_id != 0)
- g_source_remove (ping_data->ping_timeout_id);
+ g_clear_handle_id (&ping_data->ping_timeout_id, g_source_remove);
g_free (ping_data);
}
@@ -990,13 +989,8 @@ meta_display_close (MetaDisplay *display,
g_clear_object (&display->gesture_tracker);
- if (display->focus_timeout_id)
- g_source_remove (display->focus_timeout_id);
- display->focus_timeout_id = 0;
-
- if (display->tile_preview_timeout_id)
- g_source_remove (display->tile_preview_timeout_id);
- display->tile_preview_timeout_id = 0;
+ g_clear_handle_id (&display->focus_timeout_id, g_source_remove);
+ g_clear_handle_id (&display->tile_preview_timeout_id, g_source_remove);
if (display->work_area_later != 0)
meta_later_remove (display->work_area_later);
@@ -1254,8 +1248,7 @@ meta_display_queue_autoraise_callback (MetaDisplay *display,
window->desc,
meta_prefs_get_auto_raise_delay ());
- if (display->autoraise_timeout_id != 0)
- g_source_remove (display->autoraise_timeout_id);
+ g_clear_handle_id (&display->autoraise_timeout_id, g_source_remove);
display->autoraise_timeout_id =
g_timeout_add_full (G_PRIORITY_DEFAULT,
@@ -1817,11 +1810,7 @@ meta_display_begin_grab_op (MetaDisplay *display,
meta_display_update_cursor (display);
- if (display->grab_resize_timeout_id)
- {
- g_source_remove (display->grab_resize_timeout_id);
- display->grab_resize_timeout_id = 0;
- }
+ g_clear_handle_id (&display->grab_resize_timeout_id, g_source_remove);
meta_topic (META_DEBUG_WINDOW_OPS,
"Grab op %u on window %s successful\n",
@@ -1905,11 +1894,7 @@ meta_display_end_grab_op (MetaDisplay *display,
meta_display_update_cursor (display);
- if (display->grab_resize_timeout_id)
- {
- g_source_remove (display->grab_resize_timeout_id);
- display->grab_resize_timeout_id = 0;
- }
+ g_clear_handle_id (&display->grab_resize_timeout_id, g_source_remove);
if (meta_is_wayland_compositor ())
meta_display_sync_wayland_input_focus (display);
@@ -2138,11 +2123,7 @@ meta_display_pong_for_serial (MetaDisplay *display,
ping_data);
/* Remove the timeout */
- if (ping_data->ping_timeout_id != 0)
- {
- g_source_remove (ping_data->ping_timeout_id);
- ping_data->ping_timeout_id = 0;
- }
+ g_clear_handle_id (&ping_data->ping_timeout_id, g_source_remove);
meta_window_set_alive (ping_data->window, TRUE);
ping_data_free (ping_data);
@@ -2624,12 +2605,8 @@ meta_display_sanity_check_timestamps (MetaDisplay *display,
void
meta_display_remove_autoraise_callback (MetaDisplay *display)
{
- if (display->autoraise_timeout_id != 0)
- {
- g_source_remove (display->autoraise_timeout_id);
- display->autoraise_timeout_id = 0;
- display->autoraise_window = NULL;
- }
+ g_clear_handle_id (&display->autoraise_timeout_id, g_source_remove);
+ display->autoraise_window = NULL;
}
void
@@ -3141,8 +3118,7 @@ meta_display_update_tile_preview (MetaDisplay *display,
}
else
{
- if (display->tile_preview_timeout_id > 0)
- g_source_remove (display->tile_preview_timeout_id);
+ g_clear_handle_id (&display->tile_preview_timeout_id, g_source_remove);
meta_display_update_tile_preview_timeout ((gpointer)display);
}
@@ -3151,8 +3127,7 @@ meta_display_update_tile_preview (MetaDisplay *display,
void
meta_display_hide_tile_preview (MetaDisplay *display)
{
- if (display->tile_preview_timeout_id > 0)
- g_source_remove (display->tile_preview_timeout_id);
+ g_clear_handle_id (&display->tile_preview_timeout_id, g_source_remove);
display->preview_tile_mode = META_TILE_NONE;
meta_compositor_hide_tile_preview (display->compositor);
diff --git a/src/core/edge-resistance.c b/src/core/edge-resistance.c
index 65ff47408..fe3c61800 100644
--- a/src/core/edge-resistance.c
+++ b/src/core/edge-resistance.c
@@ -363,11 +363,7 @@ apply_edge_resistance (MetaWindow *window,
resistance_data->timeout_edge_pos < new_pos)))
{
resistance_data->timeout_setup = FALSE;
- if (resistance_data->timeout_id != 0)
- {
- g_source_remove (resistance_data->timeout_id);
- resistance_data->timeout_id = 0;
- }
+ g_clear_handle_id (&resistance_data->timeout_id, g_source_remove);
}
/* Get the range of indices in the edge array that we move past/to. */
@@ -784,18 +780,14 @@ meta_display_cleanup_edges (MetaDisplay *display)
edge_data->bottom_edges = NULL;
/* Cleanup the timeouts */
- if (edge_data->left_data.timeout_setup &&
- edge_data->left_data.timeout_id != 0)
- g_source_remove (edge_data->left_data.timeout_id);
- if (edge_data->right_data.timeout_setup &&
- edge_data->right_data.timeout_id != 0)
- g_source_remove (edge_data->right_data.timeout_id);
- if (edge_data->top_data.timeout_setup &&
- edge_data->top_data.timeout_id != 0)
- g_source_remove (edge_data->top_data.timeout_id);
- if (edge_data->bottom_data.timeout_setup &&
- edge_data->bottom_data.timeout_id != 0)
- g_source_remove (edge_data->bottom_data.timeout_id);
+ if (edge_data->left_data.timeout_setup)
+ g_clear_handle_id (&edge_data->left_data.timeout_id, g_source_remove);
+ if (edge_data->right_data.timeout_setup)
+ g_clear_handle_id (&edge_data->right_data.timeout_id, g_source_remove);
+ if (edge_data->top_data.timeout_setup)
+ g_clear_handle_id (&edge_data->top_data.timeout_id, g_source_remove);
+ if (edge_data->bottom_data.timeout_setup)
+ g_clear_handle_id (&edge_data->bottom_data.timeout_id, g_source_remove);
g_free (display->grab_edge_resistance_data);
display->grab_edge_resistance_data = NULL;
diff --git a/src/core/meta-close-dialog-default.c b/src/core/meta-close-dialog-default.c
index 5310f88a9..5ea32e205 100644
--- a/src/core/meta-close-dialog-default.c
+++ b/src/core/meta-close-dialog-default.c
@@ -180,11 +180,7 @@ meta_close_dialog_default_hide (MetaCloseDialog *dialog)
dialog_default = META_CLOSE_DIALOG_DEFAULT (dialog);
- if (dialog_default->child_watch_id)
- {
- g_source_remove (dialog_default->child_watch_id);
- dialog_default->child_watch_id = 0;
- }
+ g_clear_handle_id (&dialog_default->child_watch_id, g_source_remove);
if (dialog_default->dialog_pid > -1)
{
@@ -207,8 +203,7 @@ meta_close_dialog_default_finalize (GObject *object)
dialog = META_CLOSE_DIALOG_DEFAULT (object);
- if (dialog->child_watch_id)
- g_source_remove (dialog->child_watch_id);
+ g_clear_handle_id (&dialog->child_watch_id, g_source_remove);
if (dialog->dialog_pid > -1)
{
diff --git a/src/core/meta-gesture-tracker.c b/src/core/meta-gesture-tracker.c
index 0449b9a15..9bade0332 100644
--- a/src/core/meta-gesture-tracker.c
+++ b/src/core/meta-gesture-tracker.c
@@ -215,8 +215,7 @@ meta_sequence_info_new (MetaGestureTracker *tracker,
static void
meta_sequence_info_free (MetaSequenceInfo *info)
{
- if (info->autodeny_timeout_id)
- g_source_remove (info->autodeny_timeout_id);
+ g_clear_handle_id (&info->autodeny_timeout_id, g_source_remove);
if (info->state == META_SEQUENCE_NONE)
meta_gesture_tracker_set_sequence_state (info->tracker, info->sequence,
@@ -537,11 +536,7 @@ meta_gesture_tracker_set_sequence_state (MetaGestureTracker *tracker,
return FALSE;
/* Unset autodeny timeout */
- if (info->autodeny_timeout_id)
- {
- g_source_remove (info->autodeny_timeout_id);
- info->autodeny_timeout_id = 0;
- }
+ g_clear_handle_id (&info->autodeny_timeout_id, g_source_remove);
info->state = state;
g_signal_emit (tracker, signals[STATE_CHANGED], 0, sequence, info->state);
diff --git a/src/core/startup-notification.c b/src/core/startup-notification.c
index 1d4446439..99c0d9d06 100644
--- a/src/core/startup-notification.c
+++ b/src/core/startup-notification.c
@@ -531,12 +531,8 @@ meta_startup_notification_remove_sequence (MetaStartupNotification *sn,
g_signal_handlers_disconnect_by_func (seq, on_sequence_completed, sn);
- if (sn->startup_sequences == NULL &&
- sn->startup_sequence_timeout != 0)
- {
- g_source_remove (sn->startup_sequence_timeout);
- sn->startup_sequence_timeout = 0;
- }
+ if (sn->startup_sequences == NULL)
+ g_clear_handle_id (&sn->startup_sequence_timeout, g_source_remove);
g_signal_emit (sn, sn_signals[CHANGED], 0, seq);
g_object_unref (seq);
@@ -572,8 +568,7 @@ meta_startup_notification_finalize (GObject *object)
{
MetaStartupNotification *sn = META_STARTUP_NOTIFICATION (object);
- if (sn->startup_sequence_timeout)
- g_source_remove (sn->startup_sequence_timeout);
+ g_clear_handle_id (&sn->startup_sequence_timeout, g_source_remove);
g_slist_free_full (sn->startup_sequences, g_object_unref);
sn->startup_sequences = NULL;
diff --git a/src/core/util.c b/src/core/util.c
index ebf1598db..73035ea85 100644
--- a/src/core/util.c
+++ b/src/core/util.c
@@ -762,11 +762,7 @@ unref_later (MetaLater *later)
static void
destroy_later (MetaLater *later)
{
- if (later->source)
- {
- g_source_remove (later->source);
- later->source = 0;
- }
+ g_clear_handle_id (&later->source, g_source_remove);
later->func = NULL;
unref_later (later);
}
diff --git a/src/core/window.c b/src/core/window.c
index 97f08fa24..9dacdd2de 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -1430,8 +1430,7 @@ meta_window_unmanage (MetaWindow *window,
meta_verbose ("Unmanaging %s\n", window->desc);
window->unmanaging = TRUE;
- if (window->unmanage_idle_id)
- g_source_remove (window->unmanage_idle_id);
+ g_clear_handle_id (&window->unmanage_idle_id, g_source_remove);
meta_window_free_delete_dialog (window);
@@ -1540,11 +1539,7 @@ meta_window_unmanage (MetaWindow *window,
invalidate_work_areas (window);
}
- if (window->sync_request_timeout_id)
- {
- g_source_remove (window->sync_request_timeout_id);
- window->sync_request_timeout_id = 0;
- }
+ g_clear_handle_id (&window->sync_request_timeout_id, g_source_remove);
if (window->display->grab_window == window)
meta_display_end_grab_op (window->display, timestamp);
@@ -6341,11 +6336,7 @@ update_resize (MetaWindow *window,
}
/* Remove any scheduled compensation events */
- if (window->display->grab_resize_timeout_id)
- {
- g_source_remove (window->display->grab_resize_timeout_id);
- window->display->grab_resize_timeout_id = 0;
- }
+ g_clear_handle_id (&window->display->grab_resize_timeout_id, g_source_remove);
meta_window_get_frame_rect (window, &old);
@@ -8226,8 +8217,7 @@ queue_focus_callback (MetaDisplay *display,
focus_data->pointer_x = pointer_x;
focus_data->pointer_y = pointer_y;
- if (display->focus_timeout_id != 0)
- g_source_remove (display->focus_timeout_id);
+ g_clear_handle_id (&display->focus_timeout_id, g_source_remove);
display->focus_timeout_id =
g_timeout_add_full (G_PRIORITY_DEFAULT,
diff --git a/src/tests/clutter/conform/timeline.c b/src/tests/clutter/conform/timeline.c
index 96bd09277..283db7001 100644
--- a/src/tests/clutter/conform/timeline.c
+++ b/src/tests/clutter/conform/timeline.c
@@ -313,7 +313,7 @@ timeline_base (TestConformSimpleFixture *fixture,
timeline_data_destroy (&data_2);
timeline_data_destroy (&data_3);
- g_source_remove (delay_tag);
+ g_clear_handle_id (&delay_tag, g_source_remove);
clutter_actor_destroy (stage);
}
diff --git a/src/tests/clutter/interactive/test-cogl-shader-glsl.c
b/src/tests/clutter/interactive/test-cogl-shader-glsl.c
index ed4cf3e92..da7f26a70 100644
--- a/src/tests/clutter/interactive/test-cogl-shader-glsl.c
+++ b/src/tests/clutter/interactive/test-cogl-shader-glsl.c
@@ -229,11 +229,7 @@ button_release_cb (ClutterActor *actor,
/* Stop the automatic cycling if the user want to manually control
* which shader to display */
- if (timeout_id)
- {
- g_source_remove (timeout_id);
- timeout_id = 0;
- }
+ g_clear_handle_id (&timeout_id, g_source_remove);
if (event->button.button == 1)
{
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index f1ad12aa3..4f68bc6d7 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -739,11 +739,7 @@ window_created_cb (MetaDisplay *display,
g_signal_connect (window, "unmanaged",
G_CALLBACK (window_unmanaged_cb), manager);
- if (manager->xserver_grace_period_id)
- {
- g_source_remove (manager->xserver_grace_period_id);
- manager->xserver_grace_period_id = 0;
- }
+ g_clear_handle_id (&manager->xserver_grace_period_id, g_source_remove);
}
static void
diff --git a/src/x11/meta-x11-display.c b/src/x11/meta-x11-display.c
index 7b4a686c5..3e59c96c6 100644
--- a/src/x11/meta-x11-display.c
+++ b/src/x11/meta-x11-display.c
@@ -246,11 +246,7 @@ meta_x11_display_dispose (GObject *object)
x11_display->gdk_display = NULL;
}
- if (x11_display->display_close_idle)
- {
- g_source_remove (x11_display->display_close_idle);
- x11_display->display_close_idle = 0;
- }
+ g_clear_handle_id (&x11_display->display_close_idle, g_source_remove);
g_free (x11_display->name);
x11_display->name = NULL;
diff --git a/src/x11/session.c b/src/x11/session.c
index 540cbfb88..ee081236d 100644
--- a/src/x11/session.c
+++ b/src/x11/session.c
@@ -150,7 +150,7 @@ new_ice_connection (IceConn connection, IcePointer client_data, Bool opening,
{
input_id = GPOINTER_TO_UINT ((gpointer) *watch_data);
- g_source_remove (input_id);
+ g_clear_handle_id (&input_id, g_source_remove);
}
}
diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c
index 40264ee80..5389e10ac 100644
--- a/src/x11/window-x11.c
+++ b/src/x11/window-x11.c
@@ -3843,8 +3843,7 @@ meta_window_x11_update_sync_request_counter (MetaWindow *window,
window->display->grab_latest_motion_x,
window->display->grab_latest_motion_y);
- g_source_remove (window->sync_request_timeout_id);
- window->sync_request_timeout_id = 0;
+ g_clear_handle_id (&window->sync_request_timeout_id, g_source_remove);
/* This means we are ready for another configure;
* no pointer round trip here, to keep in sync */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]