From 82edc2c6da99adc9139af644bb9ba84e20ca42c0 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Thu, 5 Feb 2009 02:34:20 +0000 Subject: [PATCH] Remove annoyance. When e starts in systems under heavy load, it might not get reply from HAL before we need it, so detect batteries that still do not have filled properties and avoid calling _battery_update() if nothing is known. SVN revision: 38946 --- src/modules/battery/e_mod_main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/battery/e_mod_main.c b/src/modules/battery/e_mod_main.c index e0725fa2e..cc759cc46 100644 --- a/src/modules/battery/e_mod_main.c +++ b/src/modules/battery/e_mod_main.c @@ -258,6 +258,7 @@ struct _Hal_Battery const char *model; const char *vendor; const char *type; + Eina_Bool got_prop:1; }; struct _Hal_Ac_Adapter @@ -316,6 +317,8 @@ _battery_hal_update(void) Hal_Battery *hbat; hbat = l->data; + if (!hbat->got_prop) + continue; have_battery = 1; batnum++; if (hbat->is_charging) have_power = 1; @@ -334,6 +337,10 @@ _battery_hal_update(void) disch += hbat->is_discharging; chrg += hbat->is_charging; } + + if ((hal_batteries) && (batnum == 0)) + return; /* not ready yet, no properties received for any battery */ + if (batnum > 0) full /= batnum; if ((disch == 0) && (chrg == 0)) time_left = -1; @@ -429,7 +436,8 @@ _battery_hal_battery_props(void *data, void *reply_data, DBusError *error) GET_INT(time_left, "battery.remaining_time"); GET_BOOL(is_charging, "battery.rechargeable.is_charging"); GET_BOOL(is_discharging, "battery.rechargeable.is_discharging"); - + + hbat->got_prop = 1; _battery_hal_update(); }