linux: Don't set out_state before state is final

Currently up_device_supply_refresh_battery sets out_state before the
state value is definitive, so the wrong state value is returned to the
caller. Luckily the only caller does not make use of this value at the
moment, so there are no user-visible consequences. Nonetheless this is a
bug, so this commit fixes it.
parent f3f4c6e0
......@@ -669,7 +669,6 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply,
}
state = up_device_supply_get_state (native_path);
*out_state = state;
/* this is the new value in uW */
energy_rate = fabs (sysfs_get_double (native_path, "power_now") / 1000000.0);
......@@ -833,6 +832,8 @@ up_device_supply_refresh_battery (UpDeviceSupply *supply,
supply->priv->energy_old_first = 0;
}
*out_state = state;
g_object_set (device,
"energy", energy,
"energy-full", energy_full,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment