changeset 45:a29fbf0a7f6c

Prevent calling g_source_remove() on an invalid source ID
author Guido Berhoerster <gber@opensuse.org>
date Thu, 18 Jun 2015 13:35:55 +0200
parents cf2421217491
children aa5d3752091d
files pkui-backend.c
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pkui-backend.c	Fri Jan 09 17:09:21 2015 +0100
+++ b/pkui-backend.c	Thu Jun 18 13:35:55 2015 +0200
@@ -75,7 +75,9 @@
 	case PROP_STARTUP_DELAY:
 		self->priv->startup_delay = g_value_get_uint(value);
 
-		g_source_remove(self->priv->periodic_check_id);
+		if (self->priv->periodic_check_id != 0) {
+			g_source_remove(self->priv->periodic_check_id);
+		}
 		self->priv->periodic_check_id =
 		    g_timeout_add_seconds(self->priv->startup_delay,
 		    (GSourceFunc)periodic_check, self);
@@ -94,7 +96,9 @@
 			if (time_to_check <= 0)
 				pkui_backend_check_now(self);
 			else {
-				g_source_remove(self->priv->periodic_check_id);
+				if (self->priv->periodic_check_id != 0) {
+					g_source_remove(self->priv->periodic_check_id);
+				}
 				self->priv->periodic_check_id =
 				    g_timeout_add_seconds(time_to_check,
 				    periodic_check, self);
@@ -238,6 +242,7 @@
 	pkui_backend_check_now(self);
 
 	/* rescheduling happens after results are available */
+	self->priv->periodic_check_id = 0;
 	return (FALSE);
 }
 
@@ -310,8 +315,9 @@
 	self->priv->last_check = g_get_real_time();
 
 	if (!self->priv->inhibit_check) {
-		if (self->priv->periodic_check_id != 0)
+		if (self->priv->periodic_check_id != 0) {
 			g_source_remove(self->priv->periodic_check_id);
+		}
 		self->priv->periodic_check_id =
 			g_timeout_add_seconds(self->priv->check_interval,
 			    (GSourceFunc)periodic_check, self);