Open a window with an empty session
With general -> save-session on and only private windows open, we can easily get a session file with "windows: []" in it. If we loaded such a file, we got no windows at all when qutebrowser started. Fixes #2664
This commit is contained in:
parent
beb731c04c
commit
8bd6974042
@ -390,6 +390,7 @@ class SessionManager(QObject):
|
||||
data = yaml.load(f, Loader=YamlLoader)
|
||||
except (OSError, UnicodeDecodeError, yaml.YAMLError) as e:
|
||||
raise SessionError(e)
|
||||
|
||||
log.sessions.debug("Loading session {} from {}...".format(name, path))
|
||||
for win in data['windows']:
|
||||
window = mainwindow.MainWindow(geometry=win['geometry'],
|
||||
@ -410,7 +411,9 @@ class SessionManager(QObject):
|
||||
tabbed_browser.setCurrentIndex(tab_to_focus)
|
||||
if win.get('active', False):
|
||||
QTimer.singleShot(0, tabbed_browser.activateWindow)
|
||||
self.did_load = True
|
||||
|
||||
if data['windows']:
|
||||
self.did_load = True
|
||||
if not name.startswith('_') and not temp:
|
||||
self._current = name
|
||||
|
||||
|
@ -285,3 +285,22 @@ def test_initial_private_browsing(request, quteproc_new):
|
||||
|
||||
quteproc_new.send_cmd(':quit')
|
||||
quteproc_new.wait_for_quit()
|
||||
|
||||
|
||||
def test_loading_empty_session(tmpdir, request, quteproc_new):
|
||||
"""Make sure loading an empty session opens a window."""
|
||||
session = tmpdir / 'session.yml'
|
||||
session.write('windows: []')
|
||||
|
||||
args = _base_args(request.config) + ['--temp-basedir', '-r', str(session)]
|
||||
quteproc_new.start(args)
|
||||
|
||||
quteproc_new.compare_session("""
|
||||
windows:
|
||||
- tabs:
|
||||
- history:
|
||||
- url: about:blank
|
||||
""")
|
||||
|
||||
quteproc_new.send_cmd(':quit')
|
||||
quteproc_new.wait_for_quit()
|
||||
|
Loading…
Reference in New Issue
Block a user