~seb128/indicator-power/use-universe-translations

« back to all changes in this revision

Viewing changes to src/service.c

Fix bug that chose the wrong header icon if a connected device has a charge but its charging/discharging state is unknown. (LP: #1470080)

Show diffs side-by-side

added added

removed removed

Lines of Context:
245
245
        }
246
246
    }
247
247
 
248
 
  if (!ret) /* neither device is charging nor discharging... */
 
248
  /* neither device is charging nor discharging... */
 
249
 
 
250
  /* unless there's no other option,
 
251
     don't choose a device with an unknown state.
 
252
     https://bugs.launchpad.net/ubuntu/+source/indicator-power/+bug/1470080 */
 
253
  state = UP_DEVICE_STATE_UNKNOWN;
 
254
  if (!ret && ((a_state == state) || (b_state == state)))
 
255
    {
 
256
      if (a_state != state) /* b is unknown */
 
257
        {
 
258
          ret = -1;
 
259
        }
 
260
      else if (b_state != state) /* a is unknown */
 
261
        {
 
262
          ret = 1;
 
263
        }
 
264
    }
 
265
 
 
266
  if (!ret)
249
267
    {
250
268
      const int weight_a = get_device_kind_weight (a);
251
269
      const int weight_b = get_device_kind_weight (b);