E17: fix crash of the battery module on OpenBSD if the system has no AC adapter or battery sensor

SVN revision: 79630
This commit is contained in:
Vincent Torri 2012-11-24 10:19:55 +00:00
parent 4ff82885e8
commit 8058b50c82
1 changed files with 83 additions and 74 deletions

View File

@ -15,8 +15,8 @@ extern Eina_List *device_batteries;
extern Eina_List *device_ac_adapters;
extern double init_time;
Ac_Adapter *ac;
Battery *bat;
Ac_Adapter *ac = NULL;
Battery *bat = NULL;
int
_battery_openbsd_start(void)
@ -106,6 +106,8 @@ _battery_openbsd_battery_update()
struct sensor s;
size_t slen = sizeof(struct sensor);
if (bat)
{
/* update the poller interval */
ecore_poller_poller_interval_set(bat->poll,
battery_config->poll_interval);
@ -167,7 +169,10 @@ _battery_openbsd_battery_update()
else
bat->charging = 0;
}
}
if (ac)
{
/* AC State */
ac->mib[3] = 9;
ac->mib[4] = 0;
@ -178,8 +183,12 @@ _battery_openbsd_battery_update()
else
ac->present = 0;
}
}
if (bat)
{
if (bat->got_prop)
_battery_device_update();
bat->got_prop = 1;
}
}