projects/pk-update-icon

changeset 45:a29fbf0a7f6c

Prevent calling g_source_remove() on an invalid source ID
author Guido Berhoerster <gber@opensuse.org>
date Thu Jun 18 13:35:55 2015 +0200 (2015-06-18)
parents cf2421217491
children aa5d3752091d
files pkui-backend.c
line diff
     1.1 --- a/pkui-backend.c	Fri Jan 09 17:09:21 2015 +0100
     1.2 +++ b/pkui-backend.c	Thu Jun 18 13:35:55 2015 +0200
     1.3 @@ -75,7 +75,9 @@
     1.4  	case PROP_STARTUP_DELAY:
     1.5  		self->priv->startup_delay = g_value_get_uint(value);
     1.6  
     1.7 -		g_source_remove(self->priv->periodic_check_id);
     1.8 +		if (self->priv->periodic_check_id != 0) {
     1.9 +			g_source_remove(self->priv->periodic_check_id);
    1.10 +		}
    1.11  		self->priv->periodic_check_id =
    1.12  		    g_timeout_add_seconds(self->priv->startup_delay,
    1.13  		    (GSourceFunc)periodic_check, self);
    1.14 @@ -94,7 +96,9 @@
    1.15  			if (time_to_check <= 0)
    1.16  				pkui_backend_check_now(self);
    1.17  			else {
    1.18 -				g_source_remove(self->priv->periodic_check_id);
    1.19 +				if (self->priv->periodic_check_id != 0) {
    1.20 +					g_source_remove(self->priv->periodic_check_id);
    1.21 +				}
    1.22  				self->priv->periodic_check_id =
    1.23  				    g_timeout_add_seconds(time_to_check,
    1.24  				    periodic_check, self);
    1.25 @@ -238,6 +242,7 @@
    1.26  	pkui_backend_check_now(self);
    1.27  
    1.28  	/* rescheduling happens after results are available */
    1.29 +	self->priv->periodic_check_id = 0;
    1.30  	return (FALSE);
    1.31  }
    1.32  
    1.33 @@ -310,8 +315,9 @@
    1.34  	self->priv->last_check = g_get_real_time();
    1.35  
    1.36  	if (!self->priv->inhibit_check) {
    1.37 -		if (self->priv->periodic_check_id != 0)
    1.38 +		if (self->priv->periodic_check_id != 0) {
    1.39  			g_source_remove(self->priv->periodic_check_id);
    1.40 +		}
    1.41  		self->priv->periodic_check_id =
    1.42  			g_timeout_add_seconds(self->priv->check_interval,
    1.43  			    (GSourceFunc)periodic_check, self);