Fix lints/bugs
This commit is contained in:
parent
686f82c5c6
commit
6aeecb3803
@ -250,7 +250,7 @@ class Application(QApplication):
|
||||
url = urlutils.fuzzy_url(urlstr)
|
||||
except urlutils.FuzzyUrlError as e:
|
||||
message.error(0, "Error when opening startpage: "
|
||||
"{}".format(e))
|
||||
"{}".format(e))
|
||||
tabbed_browser.tabopen(QUrl('about:blank'))
|
||||
else:
|
||||
tabbed_browser.tabopen(url)
|
||||
@ -319,11 +319,14 @@ class Application(QApplication):
|
||||
output += self._get_registered_objects()
|
||||
return '\n'.join(output)
|
||||
|
||||
def _recover_pages(self):
|
||||
def _recover_pages(self, forgiving=False):
|
||||
"""Try to recover all open pages.
|
||||
|
||||
Called from _exception_hook, so as forgiving as possible.
|
||||
|
||||
Args:
|
||||
forgiving: Whether to ignore exceptions.
|
||||
|
||||
Return:
|
||||
A list of open pages, or an empty list.
|
||||
"""
|
||||
@ -333,12 +336,15 @@ class Application(QApplication):
|
||||
window=win_id)
|
||||
for tab in tabbed_browser.widgets():
|
||||
try:
|
||||
url = tab.cur_url.toString(
|
||||
urlstr = tab.cur_url.toString(
|
||||
QUrl.RemovePassword | QUrl.FullyEncoded)
|
||||
if url:
|
||||
pages.append(url)
|
||||
if urlstr:
|
||||
pages.append(urlstr)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
log.destroy.exception("Error while recovering tab")
|
||||
if forgiving:
|
||||
log.destroy.exception("Error while recovering tab")
|
||||
else:
|
||||
raise
|
||||
return pages
|
||||
|
||||
def _save_geometry(self):
|
||||
@ -396,7 +402,7 @@ class Application(QApplication):
|
||||
self._quit_status['crash'] = False
|
||||
|
||||
try:
|
||||
pages = self._recover_pages()
|
||||
pages = self._recover_pages(forgiving=True)
|
||||
except Exception:
|
||||
log.destroy.exception("Error while recovering pages")
|
||||
pages = []
|
||||
@ -438,19 +444,9 @@ class Application(QApplication):
|
||||
@cmdutils.register(instance='app', ignore_args=True)
|
||||
def restart(self, shutdown=True, pages=None):
|
||||
"""Restart qutebrowser while keeping existing tabs open."""
|
||||
# We don't use _recover_pages here as it's too forgiving when
|
||||
# exceptions occur.
|
||||
# FIXME handle multiple windows correctly here
|
||||
if pages is None:
|
||||
pages = []
|
||||
for win_id in objreg.window_registry:
|
||||
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||
window=win_id)
|
||||
for tab in tabbed_browser.widgets():
|
||||
urlstr = tab.cur_url.toString(
|
||||
QUrl.RemovePassword | QUrl.FullyEncoded)
|
||||
if urlstr:
|
||||
pages.append(urlstr)
|
||||
pages = self._recover_pages()
|
||||
log.destroy.debug("sys.executable: {}".format(sys.executable))
|
||||
log.destroy.debug("sys.path: {}".format(sys.path))
|
||||
log.destroy.debug("sys.argv: {}".format(sys.argv))
|
||||
|
@ -23,12 +23,11 @@ import os
|
||||
import os.path
|
||||
import tempfile
|
||||
import select
|
||||
import functools
|
||||
|
||||
from PyQt5.QtCore import (pyqtSignal, QObject, QThread, QStandardPaths,
|
||||
QProcessEnvironment, QProcess, QUrl)
|
||||
|
||||
from qutebrowser.utils import message, log, utils
|
||||
from qutebrowser.utils import message, log, utils, objreg
|
||||
from qutebrowser.commands import runners, cmdexc
|
||||
|
||||
|
||||
|
@ -87,7 +87,6 @@ class ObjectRegistry(collections.UserDict):
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
|
||||
def dump_objects(self):
|
||||
"""Dump all objects as a list of strings."""
|
||||
lines = []
|
||||
|
@ -25,7 +25,7 @@ import types
|
||||
from PyQt5.QtCore import QCoreApplication
|
||||
|
||||
from qutebrowser.utils import log, objreg, usertypes
|
||||
from qutebrowser.commands import cmdutils, runners
|
||||
from qutebrowser.commands import cmdutils, runners, cmdexc
|
||||
from qutebrowser.config import style
|
||||
|
||||
|
||||
@ -45,8 +45,8 @@ def later(ms: int, *command, win_id):
|
||||
try:
|
||||
timer.setInterval(ms)
|
||||
except OverflowError:
|
||||
raise cmdexc.CommandError("Numeric argument is too large for "
|
||||
"internal int representation.")
|
||||
raise cmdexc.CommandError("Numeric argument is too large for internal "
|
||||
"int representation.")
|
||||
cmdline = ' '.join(command)
|
||||
commandrunner = runners.CommandRunner(win_id)
|
||||
timer.timeout.connect(
|
||||
|
Loading…
Reference in New Issue
Block a user