From 80543593f10b28531c7d7207c82f64dd8ea78590 Mon Sep 17 00:00:00 2001
From: Eric Koegel <eric.koegel@gmail.com>
Date: Wed, 10 Dec 2014 19:36:56 +0300
Subject: [PATCH 11/12] Fix for GLib-CRITICAL: Source ID was not found

On remote ck session, there was a warning generated during log out.
This patch should fix that warning as well as add a couple debug
lines to help future troubleshooting. Thanks to hhoffstaette for
helping to troubleshoot this issue. For details see:
https://github.com/ConsoleKit2/ConsoleKit2/pull/15
---
 src/ck-tty-idle-monitor.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/ck-tty-idle-monitor.c b/src/ck-tty-idle-monitor.c
index 2aba92a..2b41917 100644
--- a/src/ck-tty-idle-monitor.c
+++ b/src/ck-tty-idle-monitor.c
@@ -169,6 +169,7 @@ ck_tty_idle_monitor_get_property (GObject    *object,
 static void
 remove_idle_hint_timeout (CkTtyIdleMonitor *tty_idle_monitor)
 {
+        g_debug ("remove_idle_hint_timeout: checking timeout_id %d", tty_idle_monitor->priv->timeout_id);
         if (tty_idle_monitor->priv->timeout_id > 0) {
                 g_source_remove (tty_idle_monitor->priv->timeout_id);
                 tty_idle_monitor->priv->timeout_id = 0;
@@ -225,6 +226,9 @@ check_tty_idle (CkTtyIdleMonitor *monitor)
         time_t      idletime;
         time_t      last_access;
 
+        g_debug ("check_tty_idle: setting timeout_id %d to 0", monitor->priv->timeout_id);
+        monitor->priv->timeout_id = 0;
+
         if (monitor->priv->device == NULL) {
                 return FALSE;
         }
@@ -246,8 +250,6 @@ check_tty_idle (CkTtyIdleMonitor *monitor)
 
         tty_idle_monitor_set_idle_hint_internal (monitor, is_idle);
 
-        monitor->priv->timeout_id = 0;
-
         if (is_idle) {
                 if (! monitor_add_watch (monitor)) {
                         /* if we can't add a watch just add a new timer */
@@ -275,6 +277,7 @@ static void
 schedule_tty_check (CkTtyIdleMonitor *monitor,
                     guint             seconds)
 {
+        g_debug ("schedule_tty_check: timeout_id %d", monitor->priv->timeout_id);
         if (monitor->priv->timeout_id == 0) {
 #if GLIB_CHECK_VERSION(2,14,0)
                 monitor->priv->timeout_id = g_timeout_add_seconds (seconds,
@@ -285,6 +288,7 @@ schedule_tty_check (CkTtyIdleMonitor *monitor,
                                                            (GSourceFunc)check_tty_idle,
                                                            monitor);
 #endif
+                g_debug ("schedule_tty_check: timeout_id %d", monitor->priv->timeout_id);
         }
 }
 
-- 
2.2.1

