summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Roden-Corrent <ryan@rcorre.net>2016-04-19 17:27:45 -0400
committerFlorian Bruhin <git@the-compiler.org>2016-04-30 14:41:48 +0200
commitc57bf8701e7943d871b23b6a57a3c9e912b5f7e0 (patch)
tree09a68b759100bc015892d8812d57b1254950e5d6
parentea2ae94cd0df715abf6db2c9dac16016a2a38d13 (diff)
downloadqutebrowser-c57bf8701e7943d871b23b6a57a3c9e912b5f7e0.tar.gz
qutebrowser-c57bf8701e7943d871b23b6a57a3c9e912b5f7e0.zip
Don't crash when undoing twice on default page.
Avoid a crash when undoing twice on the default page with last-close set to default-page. This was caused by logic to reuse the current tab if it is on the default page and has no history. The fix is using openurl rather than removeTab/tabopen.
-rw-r--r--qutebrowser/mainwindow/tabbedbrowser.py14
-rw-r--r--tests/integration/features/tabs.feature10
2 files changed, 20 insertions, 4 deletions
diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py
index 7c6c4e9c8..3f84dbe9f 100644
--- a/qutebrowser/mainwindow/tabbedbrowser.py
+++ b/qutebrowser/mainwindow/tabbedbrowser.py
@@ -305,6 +305,7 @@ class TabbedBrowser(tabwidget.TabWidget):
"""Undo removing of a tab."""
# Remove unused tab which may be created after the last tab is closed
last_close = config.get('tabs', 'last-close')
+ use_current_tab = False
if last_close in ['blank', 'startpage', 'default-page']:
only_one_tab_open = self.count() == 1
no_history = self.widget(0).history().count() == 1
@@ -317,12 +318,17 @@ class TabbedBrowser(tabwidget.TabWidget):
last_close_urlstr = urls[last_close].toString().rstrip('/')
first_tab_urlstr = first_tab_url.toString().rstrip('/')
last_close_url_used = first_tab_urlstr == last_close_urlstr
-
- if only_one_tab_open and no_history and last_close_url_used:
- self.removeTab(0)
+ use_current_tab = (only_one_tab_open and no_history and
+ last_close_url_used)
url, history_data = self._undo_stack.pop()
- newtab = self.tabopen(url, background=False)
+
+ if use_current_tab:
+ self.openurl(url, newtab=False)
+ newtab = self.widget(0)
+ else:
+ newtab = self.tabopen(url, background=False)
+
qtutils.deserialize(history_data, newtab.history())
@pyqtSlot('QUrl', bool)
diff --git a/tests/integration/features/tabs.feature b/tests/integration/features/tabs.feature
index b24d56cbf..5e3321505 100644
--- a/tests/integration/features/tabs.feature
+++ b/tests/integration/features/tabs.feature
@@ -607,6 +607,16 @@ Feature: Tab management
Then the following tabs should be open:
- data/hello.txt (active)
+ Scenario: Double-undo with single tab on last-close default page
+ Given I have a fresh instance
+ When I open about:blank
+ And I set tabs -> last-close to default-page
+ And I set general -> default-page to about:blank
+ And I run :undo
+ Then the error "Nothing to undo!" should be shown
+ And the following tabs should be open:
+ - about:blank (active)
+
# last-close
Scenario: last-close = blank