[Xfce4-commits] <xfce4-power-manager:master> Prevent idle being called on removed battery (bug #7851).

Nick Schermer noreply at xfce.org
Fri Apr 13 20:42:01 CEST 2012


Updating branch refs/heads/master
         to eeab7c3ab4b681cce46d76068995e62cf666750a (commit)
       from 4996f3d4efb13177f312d35bdf6cee7f7843a883 (commit)

commit eeab7c3ab4b681cce46d76068995e62cf666750a
Author: Nick Schermer <nick at xfce.org>
Date:   Fri Apr 13 20:40:48 2012 +0200

    Prevent idle being called on removed battery (bug #7851).

 src/xfpm-battery.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/xfpm-battery.c b/src/xfpm-battery.c
index 763b014..34a1da1 100644
--- a/src/xfpm-battery.c
+++ b/src/xfpm-battery.c
@@ -71,6 +71,8 @@ struct XfpmBatteryPrivate
     
     gulong		    sig;
     gulong		    sig_bt;
+    
+    guint                   notify_idle;
 };
 
 enum
@@ -360,9 +362,11 @@ xfpm_battery_notify (XfpmBattery *battery)
 static gboolean
 xfpm_battery_notify_idle (gpointer data)
 {
-    XfpmBattery *battery;
-    battery = XFPM_BATTERY (data);
+    XfpmBattery *battery = XFPM_BATTERY (data);
+    
     xfpm_battery_notify (battery);
+    battery->priv->notify_idle = 0;
+    
     return FALSE;
 }
 
@@ -390,7 +394,8 @@ xfpm_battery_notify_state (XfpmBattery *battery)
 		      
 	if ( notify )
 	{
-	    g_idle_add ((GSourceFunc) xfpm_battery_notify_idle, battery);
+	    if (battery->priv->notify_idle == 0)
+	        battery->priv->notify_idle = g_idle_add (xfpm_battery_notify_idle, battery);
 	}
     }
 }
@@ -764,7 +769,10 @@ xfpm_battery_finalize (GObject *object)
     battery = XFPM_BATTERY (object);
     
     g_free (battery->priv->icon_prefix);
-    
+
+    if (battery->priv->notify_idle != 0)
+        g_source_remove (battery->priv->notify_idle);
+
     dbus_g_proxy_disconnect_signal (battery->priv->proxy, "Changed",
 				    G_CALLBACK (xfpm_battery_changed_cb), battery);
 				    


More information about the Xfce4-commits mailing list