From f223d5a98db5fc1505ffcd04941093856ba0b3fb Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 15 May 2017 14:54:40 +0200 Subject: Fix bug that chose the wrong header icon if a connected device has a charge but its charging/discharging state is unknown. (LP: #1470080). --- src/service.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/service.c') diff --git a/src/service.c b/src/service.c index 679dc5e..76a0db9 100644 --- a/src/service.c +++ b/src/service.c @@ -243,7 +243,25 @@ device_compare_func (gconstpointer ga, gconstpointer gb) } } - if (!ret) /* neither device is charging nor discharging... */ + /* neither device is charging nor discharging... */ + + /* unless there's no other option, + don't choose a device with an unknown state. + https://bugs.launchpad.net/ubuntu/+source/indicator-power/+bug/1470080 */ + state = UP_DEVICE_STATE_UNKNOWN; + if (!ret && ((a_state == state) || (b_state == state))) + { + if (a_state != state) /* b is unknown */ + { + ret = -1; + } + else if (b_state != state) /* a is unknown */ + { + ret = 1; + } + } + + if (!ret) { const int weight_a = get_device_kind_weight (a); const int weight_b = get_device_kind_weight (b); -- cgit v1.2.3