From 116adf9959d0e8fa64b0ddd39a9cdb1a2d58f979 Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Mon, 11 Oct 2021 20:40:57 -0400 Subject: [PATCH] ui: better computation of tray index when adding devices --- lib/solaar/ui/tray.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/solaar/ui/tray.py b/lib/solaar/ui/tray.py index 0d8abc66..bd1da005 100644 --- a/lib/solaar/ui/tray.py +++ b/lib/solaar/ui/tray.py @@ -359,15 +359,16 @@ def _add_device(device): receiver_path = device.receiver.path if device.receiver is not None else device.path # not true for wired devices - assert receiver_path - index = 0 + index = None for idx, (path, _ignore, _ignore, _ignore) in enumerate(_devices_info): if path == receiver_path: # the first entry matching the receiver serial should be for the receiver itself index = idx + 1 break - # assert index is not None - if device.receiver: + if index is None: + index = len(_devices_info) + elif device.receiver: # proper ordering (according to device.number) for a receiver's devices while True: path, number, _ignore, _ignore = _devices_info[index]