summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Schermer <nick@xfce.org>2012-04-13 20:40:48 +0200
committerNick Schermer <nick@xfce.org>2012-04-13 20:40:48 +0200
commiteeab7c3ab4b681cce46d76068995e62cf666750a (patch)
treef687e46dc373e7561f2d715c96ed20a3f5a459c0
parent4996f3d4efb13177f312d35bdf6cee7f7843a883 (diff)
downloadixfce4-power-manager-eeab7c3ab4b681cce46d76068995e62cf666750a.tar.gz
Prevent idle being called on removed battery (bug #7851).
-rw-r--r--src/xfpm-battery.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/xfpm-battery.c b/src/xfpm-battery.c
index 763b014b..34a1da1f 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);