Fix QTBUG-54419 workaround with tabs-are-windows set

Fixes #2162
This commit is contained in:
Florian Bruhin 2016-12-07 07:01:06 +01:00
parent 1536a3324e
commit 57adcea587
2 changed files with 25 additions and 3 deletions

View File

@ -346,7 +346,8 @@ class TabbedBrowser(tabwidget.TabWidget):
@pyqtSlot('QUrl')
@pyqtSlot('QUrl', bool)
def tabopen(self, url=None, background=None, explicit=False, idx=None):
def tabopen(self, url=None, background=None, explicit=False, idx=None, *,
ignore_tabs_are_windows=False):
"""Open a new tab with a given URL.
Inner logic for open-tab and open-tab-bg.
@ -363,6 +364,8 @@ class TabbedBrowser(tabwidget.TabWidget):
the current.
- Explicitly opened tabs are at the very right.
idx: The index where the new tab should be opened.
ignore_tabs_are_windows: If given, never open a new window, even
with tabs-are-windows set.
Return:
The opened WebView instance.
@ -373,7 +376,8 @@ class TabbedBrowser(tabwidget.TabWidget):
"explicit {}, idx {}".format(
url, background, explicit, idx))
if config.get('tabs', 'tabs-are-windows') and self.count() > 0:
if (config.get('tabs', 'tabs-are-windows') and self.count() > 0 and
not ignore_tabs_are_windows):
from qutebrowser.mainwindow import mainwindow
window = mainwindow.MainWindow()
window.show()
@ -528,7 +532,8 @@ class TabbedBrowser(tabwidget.TabWidget):
background = self.currentIndex() != idx
self.setUpdatesEnabled(False)
try:
self.tabopen(url, background=background, idx=idx)
self.tabopen(url, background=background, idx=idx,
ignore_tabs_are_windows=True)
self.close_tab(tab, add_undo=False)
finally:
self.setUpdatesEnabled(True)

View File

@ -973,6 +973,8 @@ Feature: Tab management
And I run :buffer "1/2/3"
Then the error "No matching tab for: 1/2/3" should be shown
# Other
Scenario: Using :tab-next after closing last tab (#1448)
When I set tabs -> last-close to close
And I run :tab-only
@ -986,3 +988,18 @@ Feature: Tab management
And I run :tab-close ;; tab-prev
Then qutebrowser should quit
And no crash should happen
Scenario: Opening link with tabs-are-windows set (#2162)
When I set tabs -> tabs-are-windows to true
And I open data/hints/html/simple.html
And I hint with args "all tab-fg" and follow a
And I wait until data/hello.txt is loaded
Then the session should look like:
windows:
- tabs:
- history:
- url: about:blank
- url: http://localhost:*/data/hints/html/simple.html
- tabs:
- history:
- url: http://localhost:*/data/hello.txt