Fix crash when closing tab then doing tab-focus-last.

This commit is contained in:
Florian Bruhin 2014-07-29 22:42:59 +02:00
parent 8ce779261f
commit cf8a8ad3b4
2 changed files with 6 additions and 0 deletions

View File

@ -572,6 +572,8 @@ class CommandDispatcher:
@cmdutils.register(instance='mainwindow.tabs.cmd')
def tab_focus_last(self):
"""Select the tab which was last focused."""
if self._tabs.last_focused is None:
raise CommandError("No last focused tab!")
idx = self._tabs.indexOf(self._tabs.last_focused)
if idx == -1:
raise CommandError("Last focused tab vanished!")

View File

@ -268,6 +268,10 @@ class TabbedBrowser(TabWidget):
tab = self.widget(idx)
if tab is None:
raise ValueError("invalid index {}!".format(idx))
if tab is self.now_focused:
self.now_focused = None
if tab is self.last_focused:
self.last_focused = None
last_close = config.get('tabbar', 'last-close')
if self.count() > 1:
url = tab.url()