From 4bfa1c4c03a23c27a752b97a343859b8658502c8 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Fri, 5 Sep 2014 13:56:53 -0700 Subject: [PATCH] Fix another crash on prev/next change If the currently displayed change was opened via a link and there is a change list in the navigation hierarchy, Gertty will find the change list but not the current change. Protect against a crash in that case and do nothing. Change-Id: I85b00b8cf6af258b672f15352b75803d931c59a6 --- gertty/view/change_list.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gertty/view/change_list.py b/gertty/view/change_list.py index 70db0f5..f723388 100644 --- a/gertty/view/change_list.py +++ b/gertty/view/change_list.py @@ -148,7 +148,10 @@ class ChangeListView(urwid.WidgetWrap): def getNextChangeKey(self, change_key): row = self.change_rows.get(change_key) - i = self.listbox.body.index(row) + try: + i = self.listbox.body.index(row) + except ValueError: + return None if i+1 >= len(self.listbox.body): return None row = self.listbox.body[i+1] @@ -156,7 +159,10 @@ class ChangeListView(urwid.WidgetWrap): def getPrevChangeKey(self, change_key): row = self.change_rows.get(change_key) - i = self.listbox.body.index(row) + try: + i = self.listbox.body.index(row) + except ValueError: + return None if i <= 0: return None row = self.listbox.body[i-1]