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
This commit is contained in:
Gustavo Sverzut Barbieri 2009-02-05 02:34:20 +00:00
parent d6e765033d
commit 82edc2c6da
1 changed files with 9 additions and 1 deletions

View File

@ -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();
}