Merge branch 'master' of https://github.com/The-Compiler/qutebrowser
This commit is contained in:
commit
f0d0d92124
@ -574,6 +574,11 @@ class Application(QApplication):
|
||||
args = [sys.executable, '-m', 'qutebrowser']
|
||||
cwd = os.path.join(os.path.abspath(os.path.dirname(
|
||||
qutebrowser.__file__)), '..')
|
||||
if not os.path.isdir(cwd):
|
||||
# Probably running from an python egg. Let's fallback to
|
||||
# cwd=None and see if that works out.
|
||||
# See https://github.com/The-Compiler/qutebrowser/issues/323
|
||||
cwd = None
|
||||
for arg in sys.argv[1:]:
|
||||
if arg.startswith('-'):
|
||||
# We only want to preserve options on a restart.
|
||||
@ -598,15 +603,15 @@ class Application(QApplication):
|
||||
log.destroy.debug("sys.path: {}".format(sys.path))
|
||||
log.destroy.debug("sys.argv: {}".format(sys.argv))
|
||||
log.destroy.debug("frozen: {}".format(hasattr(sys, 'frozen')))
|
||||
args, cwd = self._get_restart_args(pages)
|
||||
# Open a new process and immediately shutdown the existing one
|
||||
try:
|
||||
args, cwd = self._get_restart_args(pages)
|
||||
if cwd is None:
|
||||
subprocess.Popen(args)
|
||||
else:
|
||||
subprocess.Popen(args, cwd=cwd)
|
||||
except OSError as e:
|
||||
log.destroy.error("Failed to restart: {}".format(e))
|
||||
except OSError:
|
||||
log.destroy.exception("Failed to restart")
|
||||
else:
|
||||
if shutdown:
|
||||
self.shutdown()
|
||||
|
@ -20,6 +20,7 @@
|
||||
"""The main browser widgets."""
|
||||
|
||||
import itertools
|
||||
import functools
|
||||
|
||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QTimer, QUrl
|
||||
from PyQt5.QtWidgets import QApplication
|
||||
@ -96,7 +97,13 @@ class WebView(QWebView):
|
||||
self._zoom = None
|
||||
self._has_ssl_errors = False
|
||||
self.init_neighborlist()
|
||||
objreg.get('config').changed.connect(self.init_neighborlist)
|
||||
cfg = objreg.get('config')
|
||||
cfg.changed.connect(self.init_neighborlist)
|
||||
# For some reason, this signal doesn't get disconnected automatically
|
||||
# when the WebView is destroyed on older PyQt versions.
|
||||
# See https://github.com/The-Compiler/qutebrowser/issues/390
|
||||
self.destroyed.connect(functools.partial(
|
||||
cfg.changed.disconnect, self.init_neighborlist))
|
||||
self._cur_url = None
|
||||
self.cur_url = QUrl()
|
||||
self.progress = 0
|
||||
|
@ -41,6 +41,11 @@ FIRST_COMMENT = r"""
|
||||
|
||||
# Configfile for qutebrowser.
|
||||
#
|
||||
# WARNING:
|
||||
#
|
||||
# This config file will be OVERWRITTEN when closing qutebrowser.
|
||||
# Close qutebrowser before changing this file, or YOUR CHANGES WILL BE LOST.
|
||||
#
|
||||
# This configfile is parsed by python's configparser in extended
|
||||
# interpolation mode. The format is very INI-like, so there are
|
||||
# categories like [general] with "key = value"-pairs.
|
||||
|
@ -287,9 +287,6 @@ class ModeManager(QObject):
|
||||
mode, '' if reason is None else ' (reason: {})'.format(reason)))
|
||||
if mode not in self._handlers:
|
||||
raise ValueError("No handler for mode {}".format(mode))
|
||||
if self.mode_stack and self.mode_stack[-1] == mode:
|
||||
log.modes.debug("Already at end of stack, doing nothing")
|
||||
return
|
||||
self.mode_stack.append(mode)
|
||||
log.modes.debug("New mode stack: {}".format(self.mode_stack))
|
||||
self.entered.emit(mode, self._win_id)
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
"""Manager for questions to be shown in the statusbar."""
|
||||
|
||||
import sip
|
||||
import collections
|
||||
|
||||
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QTimer, QObject
|
||||
@ -95,7 +96,12 @@ class Prompter(QObject):
|
||||
"""Pop a question from the queue and ask it, if there are any."""
|
||||
log.statusbar.debug("Popping from queue {}".format(self._queue))
|
||||
if self._queue:
|
||||
self.ask_question(self._queue.popleft(), blocking=False)
|
||||
question = self._queue.popleft()
|
||||
if not sip.isdeleted(question):
|
||||
# the question could already be deleted, e.g. by a cancelled
|
||||
# download. See
|
||||
# https://github.com/The-Compiler/qutebrowser/issues/415
|
||||
self.ask_question(question, blocking=False)
|
||||
|
||||
def _get_ctx(self):
|
||||
"""Get a PromptContext based on the current state."""
|
||||
|
@ -318,13 +318,14 @@ class ExceptionCrashDialog(_CrashDialog):
|
||||
("Command history", '\n'.join(self._cmdhist)),
|
||||
("Objects", self._objects),
|
||||
]
|
||||
super()._gather_crash_info()
|
||||
if self._chk_log.isChecked():
|
||||
try:
|
||||
self._crash_info.append(
|
||||
("Debug log", log.ram_handler.dump_log()))
|
||||
except Exception:
|
||||
self._crash_info.append(
|
||||
("Debug log", traceback.format_exc()))
|
||||
super()._gather_crash_info()
|
||||
|
||||
@pyqtSlot()
|
||||
def on_chk_report_toggled(self):
|
||||
@ -407,6 +408,7 @@ class ReportDialog(_CrashDialog):
|
||||
self._btn_report.clicked.connect(
|
||||
functools.partial(self.on_button_clicked, self._btn_report, True))
|
||||
self._hbox.addWidget(self._btn_report)
|
||||
self._buttons = [self._btn_report]
|
||||
|
||||
def _init_checkboxes(self, _debug):
|
||||
"""We don't want any checkboxes as the user wanted to report."""
|
||||
|
@ -152,11 +152,11 @@ class IPCServer(QObject):
|
||||
return
|
||||
try:
|
||||
args = json_data['args']
|
||||
cwd = json_data['cwd']
|
||||
except KeyError:
|
||||
log.ipc.error("Ignoring invalid IPC data.")
|
||||
log.ipc.debug("no args/cwd: {}".format(decoded.strip()))
|
||||
log.ipc.debug("no args: {}".format(decoded.strip()))
|
||||
return
|
||||
cwd = json_data.get('cwd', None)
|
||||
app = objreg.get('app')
|
||||
app.process_args(args, via_ipc=True, cwd=cwd)
|
||||
|
||||
@ -211,7 +211,13 @@ def send_to_running_instance(cmdlist):
|
||||
connected = socket.waitForConnected(100)
|
||||
if connected:
|
||||
log.ipc.info("Opening in existing instance")
|
||||
json_data = {'args': cmdlist, 'cwd': os.getcwd()}
|
||||
json_data = {'args': cmdlist}
|
||||
try:
|
||||
cwd = os.getcwd()
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
json_data['cwd'] = cwd
|
||||
line = json.dumps(json_data) + '\n'
|
||||
data = line.encode('utf-8')
|
||||
log.ipc.debug("Writing: {}".format(data))
|
||||
|
@ -136,18 +136,14 @@ def fuzzy_url(urlstr, cwd=None):
|
||||
if cwd:
|
||||
path = os.path.join(cwd, os.path.expanduser(urlstr))
|
||||
else:
|
||||
path = os.path.abspath(os.path.expanduser(urlstr))
|
||||
try:
|
||||
path = os.path.abspath(os.path.expanduser(urlstr))
|
||||
except OSError:
|
||||
path = None
|
||||
stripped = urlstr.strip()
|
||||
if os.path.exists(path):
|
||||
if path is not None and os.path.exists(path):
|
||||
log.url.debug("URL is a local file")
|
||||
url = QUrl.fromLocalFile(path)
|
||||
elif (not _has_explicit_scheme(QUrl(urlstr)) and
|
||||
os.path.exists(path)):
|
||||
# We do this here rather than in the first block because we first want
|
||||
# to make sure it's not an URL like http://, because os.path.abspath
|
||||
# would mangle that.
|
||||
log.url.debug("URL is a relative local file")
|
||||
url = QUrl.fromLocalFile(path)
|
||||
elif is_url(stripped):
|
||||
# probably an address
|
||||
log.url.debug("URL is a fuzzy address")
|
||||
|
@ -64,7 +64,7 @@ def _git_str():
|
||||
try:
|
||||
gitpath = os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
||||
os.path.pardir, os.path.pardir)
|
||||
except NameError:
|
||||
except (NameError, OSError):
|
||||
log.misc.exception("Error while getting git path")
|
||||
else:
|
||||
commit = _git_str_subprocess(gitpath)
|
||||
|
Loading…
Reference in New Issue
Block a user