[gnome-color-manager] trivial: Use the new g_source_set_name_by_id() functionality, and generally be more paranoid removin
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] trivial: Use the new g_source_set_name_by_id() functionality, and generally be more paranoid removin
- Date: Tue, 25 May 2010 20:34:15 +0000 (UTC)
commit e8c8b121859da2b239a75837c1c4418ed7753499
Author: Richard Hughes <richard hughsie com>
Date: Tue May 25 21:34:03 2010 +0100
trivial: Use the new g_source_set_name_by_id() functionality, and generally be more paranoid removing sources
src/gcm-calibrate-argyll.c | 11 ++++++++++-
src/gcm-client.c | 26 +++++++++++++++++++++++---
src/gcm-device.c | 3 +++
src/gcm-session.c | 13 ++++++++++---
4 files changed, 46 insertions(+), 7 deletions(-)
---
diff --git a/src/gcm-calibrate-argyll.c b/src/gcm-calibrate-argyll.c
index 245b3f8..a49a09f 100644
--- a/src/gcm-calibrate-argyll.c
+++ b/src/gcm-calibrate-argyll.c
@@ -84,6 +84,7 @@ struct _GcmCalibrateArgyllPrivate
GcmPrint *print;
const gchar *argyllcms_ok;
gboolean done_spot_read;
+ guint keypress_id;
};
enum {
@@ -2234,7 +2235,12 @@ gcm_calibrate_argyll_interaction_attach (GcmCalibrateArgyll *calibrate_argyll)
/* different tools assume the device is not on the screen */
if (priv->already_on_window) {
egg_debug ("VTE: already on screen so faking keypress");
- g_timeout_add_seconds (1, (GSourceFunc) gcm_calibrate_argyll_timeout_cb, calibrate_argyll);
+ priv->keypress_id = g_timeout_add_seconds (1,
+ (GSourceFunc) gcm_calibrate_argyll_timeout_cb,
+ calibrate_argyll);
+#if GLIB_CHECK_VERSION(2,25,8)
+ g_source_set_name_by_id (priv->keypress_id, "[GcmCalibrateArgyll] keypress faker");
+#endif
goto out;
}
@@ -2954,6 +2960,9 @@ gcm_calibrate_argyll_finalize (GObject *object)
/* hide */
gcm_calibrate_dialog_hide (priv->calibrate_dialog);
+ if (priv->keypress_id != 0)
+ g_source_remove (priv->keypress_id);
+
g_main_loop_unref (priv->loop);
g_object_unref (priv->screen);
g_object_unref (priv->calibrate_dialog);
diff --git a/src/gcm-client.c b/src/gcm-client.c
index f5d2329..9cb10ad 100644
--- a/src/gcm-client.c
+++ b/src/gcm-client.c
@@ -81,6 +81,7 @@ struct _GcmClientPrivate
gboolean use_threads;
gboolean init_cups;
gboolean init_sane;
+ guint refresh_id;
};
enum {
@@ -442,7 +443,14 @@ gcm_client_uevent_cb (GUdevClient *gudev_client, const gchar *action, GUdevDevic
}
/* find any others that might still be connected */
- g_timeout_add (GCM_CLIENT_SANE_REMOVED_TIMEOUT, (GSourceFunc) gcm_client_sane_refresh_cb, client);
+ if (priv->refresh_id != 0)
+ g_source_remove (priv->refresh_id);
+ priv->refresh_id = g_timeout_add (GCM_CLIENT_SANE_REMOVED_TIMEOUT,
+ (GSourceFunc) gcm_client_sane_refresh_cb,
+ client);
+#if GLIB_CHECK_VERSION(2,25,8)
+ g_source_set_name_by_id (priv->refresh_id, "[GcmClient] refresh due to device remove");
+#endif
}
#endif
@@ -454,8 +462,16 @@ gcm_client_uevent_cb (GUdevClient *gudev_client, const gchar *action, GUdevDevic
#ifdef GCM_USE_SANE
/* we need to rescan scanner devices */
value = g_udev_device_get_property (udev_device, "GCM_RESCAN");
- if (g_strcmp0 (value, "scanner") == 0)
- g_timeout_add (GCM_CLIENT_SANE_REMOVED_TIMEOUT, (GSourceFunc) gcm_client_sane_refresh_cb, client);
+ if (g_strcmp0 (value, "scanner") == 0) {
+ if (priv->refresh_id != 0)
+ g_source_remove (priv->refresh_id);
+ priv->refresh_id = g_timeout_add (GCM_CLIENT_SANE_REMOVED_TIMEOUT,
+ (GSourceFunc) gcm_client_sane_refresh_cb,
+ client);
+#if GLIB_CHECK_VERSION(2,25,8)
+ g_source_set_name_by_id (priv->refresh_id, "[GcmClient] refresh due to device add");
+#endif
+ }
#endif
}
}
@@ -1420,6 +1436,10 @@ gcm_client_finalize (GObject *object)
GcmDevice *device;
guint i;
+ /* disconnect anything that's about to fire */
+ if (priv->refresh_id != 0)
+ g_source_remove (priv->refresh_id);
+
/* do not respond to changed events */
for (i=0; i<priv->array->len; i++) {
device = g_ptr_array_index (priv->array, i);
diff --git a/src/gcm-device.c b/src/gcm-device.c
index 8375c9c..71b6b2b 100644
--- a/src/gcm-device.c
+++ b/src/gcm-device.c
@@ -130,6 +130,9 @@ gcm_device_changed (GcmDevice *device)
(GSourceFunc) gcm_device_changed_cb,
g_object_ref (device),
(GDestroyNotify) g_object_unref);
+#if GLIB_CHECK_VERSION(2,25,8)
+ g_source_set_name_by_id (device->priv->changed_id, "[GcmDevice] device changed");
+#endif
out:
/* unlock */
g_static_mutex_unlock (&mutex);
diff --git a/src/gcm-session.c b/src/gcm-session.c
index 7ec94ac..6a0dff2 100644
--- a/src/gcm-session.c
+++ b/src/gcm-session.c
@@ -728,6 +728,7 @@ main (int argc, char *argv[])
gboolean ret;
guint retval = 1;
guint owner_id = 0;
+ guint poll_id = 0;
GFile *file = NULL;
gchar *introspection_data = NULL;
@@ -812,9 +813,13 @@ main (int argc, char *argv[])
gcm_session_on_name_lost,
NULL, NULL);
- /* only timeout if we have specified iton the command line */
- if (!no_timed_exit)
- g_timeout_add_seconds (5, (GSourceFunc) gcm_session_check_idle_cb, NULL);
+ /* only timeout if we have specified it on the command line */
+ if (!no_timed_exit) {
+ poll_id = g_timeout_add_seconds (5, (GSourceFunc) gcm_session_check_idle_cb, NULL);
+#if GLIB_CHECK_VERSION(2,25,8)
+ g_source_set_name_by_id (poll_id, "[GcmSession] inactivity checker");
+#endif
+ }
/* wait */
g_main_loop_run (loop);
@@ -823,6 +828,8 @@ main (int argc, char *argv[])
retval = 0;
out:
g_free (introspection_data);
+ if (poll_id != 0)
+ g_source_remove (poll_id);
if (file != NULL)
g_object_unref (file);
if (owner_id > 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]