Fix crash on prev/next change

When the currently displayed change was not arrived at from a
query listing (for example, was directly opened), there may be no
change list to find in the navigation history.  Don't try to use
it if that's the case.

Change-Id: I6fdb1ed2e16675bf1be3726b836130b695225b6b
This commit is contained in:
James E. Blair 2014-09-05 13:26:09 -07:00
parent 7d5b02d9af
commit 954ca7dfb0
1 changed files with 13 additions and 11 deletions

View File

@ -735,21 +735,23 @@ class ChangeView(urwid.WidgetWrap):
return None
if keymap.SEARCH_RESULTS in commands:
widget = self.app.findChangeList()
self.app.backScreen(widget)
if widget:
self.app.backScreen(widget)
return None
if ((keymap.NEXT_CHANGE in commands) or
(keymap.PREV_CHANGE in commands)):
widget = self.app.findChangeList()
if keymap.NEXT_CHANGE in commands:
new_change_key = widget.getNextChangeKey(self.change_key)
else:
new_change_key = widget.getPrevChangeKey(self.change_key)
if new_change_key:
try:
view = ChangeView(self.app, new_change_key)
self.app.changeScreen(view, push=False)
except gertty.view.DisplayError as e:
self.app.error(e.message)
if widget:
if keymap.NEXT_CHANGE in commands:
new_change_key = widget.getNextChangeKey(self.change_key)
else:
new_change_key = widget.getPrevChangeKey(self.change_key)
if new_change_key:
try:
view = ChangeView(self.app, new_change_key)
self.app.changeScreen(view, push=False)
except gertty.view.DisplayError as e:
self.app.error(e.message)
return None
if keymap.TOGGLE_HIDDEN_COMMENTS in commands:
self.hide_comments = not self.hide_comments