Merge branch 'cosminadrianpopescu-session-autosave'
This commit is contained in:
commit
2c03ad34ad
@ -32,6 +32,7 @@ Added
|
|||||||
- Support for the `general -> print-element-backgrounds` option with QtWebEngine on Qt >= 5.8
|
- Support for the `general -> print-element-backgrounds` option with QtWebEngine on Qt >= 5.8
|
||||||
- Support for `:download --mhtml` with QtWebEngine
|
- Support for `:download --mhtml` with QtWebEngine
|
||||||
- New `qute:history` URL and `:history` command to show the browsing history.
|
- New `qute:history` URL and `:history` command to show the browsing history.
|
||||||
|
- Open tabs are now auto-saved on each successful load and restored in case of a crash.
|
||||||
|
|
||||||
Changed
|
Changed
|
||||||
~~~~~~~
|
~~~~~~~
|
||||||
|
@ -211,6 +211,7 @@ Contributors, sorted by the number of commits in descending order:
|
|||||||
* Michael Ilsaas
|
* Michael Ilsaas
|
||||||
* Martin Zimmermann
|
* Martin Zimmermann
|
||||||
* Jussi Timperi
|
* Jussi Timperi
|
||||||
|
* Cosmin Popescu
|
||||||
* Brian Jackson
|
* Brian Jackson
|
||||||
* thuck
|
* thuck
|
||||||
* sbinix
|
* sbinix
|
||||||
|
@ -214,14 +214,17 @@ def _load_session(name):
|
|||||||
name: The name of the session to load, or None to read state file.
|
name: The name of the session to load, or None to read state file.
|
||||||
"""
|
"""
|
||||||
state_config = objreg.get('state-config')
|
state_config = objreg.get('state-config')
|
||||||
if name is None:
|
session_manager = objreg.get('session-manager')
|
||||||
|
if name is None and session_manager.exists('_autosave'):
|
||||||
|
name = '_autosave'
|
||||||
|
elif name is None:
|
||||||
try:
|
try:
|
||||||
name = state_config['general']['session']
|
name = state_config['general']['session']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# No session given as argument and none in the session file ->
|
# No session given as argument and none in the session file ->
|
||||||
# start without loading a session
|
# start without loading a session
|
||||||
return
|
return
|
||||||
session_manager = objreg.get('session-manager')
|
|
||||||
try:
|
try:
|
||||||
session_manager.load(name)
|
session_manager.load(name)
|
||||||
except sessions.SessionNotFoundError:
|
except sessions.SessionNotFoundError:
|
||||||
@ -720,6 +723,11 @@ class Quitter:
|
|||||||
# Now we can hopefully quit without segfaults
|
# Now we can hopefully quit without segfaults
|
||||||
log.destroy.debug("Deferring QApplication::exit...")
|
log.destroy.debug("Deferring QApplication::exit...")
|
||||||
objreg.get('signal-handler').deactivate()
|
objreg.get('signal-handler').deactivate()
|
||||||
|
try:
|
||||||
|
objreg.get('session-manager').delete('_autosave')
|
||||||
|
except sessions.SessionError as e:
|
||||||
|
log.sessions.error("Failed to delete autosave session: {}"
|
||||||
|
.format(e))
|
||||||
# We use a singleshot timer to exit here to minimize the likelihood of
|
# We use a singleshot timer to exit here to minimize the likelihood of
|
||||||
# segfaults.
|
# segfaults.
|
||||||
QTimer.singleShot(0, functools.partial(qApp.exit, status))
|
QTimer.singleShot(0, functools.partial(qApp.exit, status))
|
||||||
|
@ -28,7 +28,7 @@ from PyQt5.QtWidgets import QWidget, QApplication
|
|||||||
from qutebrowser.keyinput import modeman
|
from qutebrowser.keyinput import modeman
|
||||||
from qutebrowser.config import config
|
from qutebrowser.config import config
|
||||||
from qutebrowser.utils import utils, objreg, usertypes, log, qtutils
|
from qutebrowser.utils import utils, objreg, usertypes, log, qtutils
|
||||||
from qutebrowser.misc import miscwidgets, objects
|
from qutebrowser.misc import miscwidgets, objects, sessions
|
||||||
from qutebrowser.browser import mouse, hints
|
from qutebrowser.browser import mouse, hints
|
||||||
|
|
||||||
|
|
||||||
@ -684,12 +684,17 @@ class AbstractTab(QWidget):
|
|||||||
|
|
||||||
@pyqtSlot(bool)
|
@pyqtSlot(bool)
|
||||||
def _on_load_finished(self, ok):
|
def _on_load_finished(self, ok):
|
||||||
|
sess_manager = objreg.get('session-manager')
|
||||||
|
try:
|
||||||
|
sess_manager.save('_autosave')
|
||||||
|
except sessions.SessionError as e:
|
||||||
|
log.sessions.error("Failed to save autosave session: {}".format(e))
|
||||||
|
|
||||||
if ok and not self._has_ssl_errors:
|
if ok and not self._has_ssl_errors:
|
||||||
if self.url().scheme() == 'https':
|
if self.url().scheme() == 'https':
|
||||||
self._set_load_status(usertypes.LoadStatus.success_https)
|
self._set_load_status(usertypes.LoadStatus.success_https)
|
||||||
else:
|
else:
|
||||||
self._set_load_status(usertypes.LoadStatus.success)
|
self._set_load_status(usertypes.LoadStatus.success)
|
||||||
|
|
||||||
elif ok:
|
elif ok:
|
||||||
self._set_load_status(usertypes.LoadStatus.warn)
|
self._set_load_status(usertypes.LoadStatus.warn)
|
||||||
else:
|
else:
|
||||||
|
@ -34,7 +34,6 @@ except ImportError: # pragma: no cover
|
|||||||
from qutebrowser.utils import (standarddir, objreg, qtutils, log, usertypes,
|
from qutebrowser.utils import (standarddir, objreg, qtutils, log, usertypes,
|
||||||
message, utils)
|
message, utils)
|
||||||
from qutebrowser.commands import cmdexc, cmdutils
|
from qutebrowser.commands import cmdexc, cmdutils
|
||||||
from qutebrowser.mainwindow import mainwindow
|
|
||||||
from qutebrowser.config import config
|
from qutebrowser.config import config
|
||||||
|
|
||||||
|
|
||||||
@ -346,6 +345,7 @@ class SessionManager(QObject):
|
|||||||
name: The name of the session to load.
|
name: The name of the session to load.
|
||||||
temp: If given, don't set the current session.
|
temp: If given, don't set the current session.
|
||||||
"""
|
"""
|
||||||
|
from qutebrowser.mainwindow import mainwindow
|
||||||
path = self._get_session_path(name, check_exists=True)
|
path = self._get_session_path(name, check_exists=True)
|
||||||
try:
|
try:
|
||||||
with open(path, encoding='utf-8') as f:
|
with open(path, encoding='utf-8') as f:
|
||||||
|
Loading…
Reference in New Issue
Block a user