Fix uncaught exception on channel list key navigation

After searching, the channel list treeview sometimes does not have a
selected item, leading to an invalid iterator when navigating the list
with arrow keys.

Select the first episode item in the TreeView model in this case.
This commit is contained in:
Teemu Ikonen 2020-12-30 14:27:48 +02:00
parent 33a144f985
commit 0cd1d12c20
1 changed files with 6 additions and 3 deletions

View File

@ -717,14 +717,17 @@ class gPodder(BuilderWidget, dbus.service.Object):
elif event.keyval in (Gdk.KEY_Up, Gdk.KEY_Down):
# If section markers exist in the treeview, we want to
# "jump over" them when moving the cursor up and down
selection = self.treeChannels.get_selection()
model, it = selection.get_selected()
if event.keyval == Gdk.KEY_Up:
step = -1
else:
step = 1
selection = self.treeChannels.get_selection()
model, it = selection.get_selected()
if it is None:
it = model.get_iter_first()
step = 1
path = model.get_path(it)
while True:
path = (path[0] + step,)