diff --git a/qutebrowser/app.py b/qutebrowser/app.py index 73485a634..16f5083a7 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -732,6 +732,7 @@ class Application(QApplication): Attributes: _args: ArgumentParser instance. + _last_focus_object: The last focused object's repr. """ new_window = pyqtSignal(mainwindow.MainWindow) @@ -742,6 +743,8 @@ class Application(QApplication): Args: Argument namespace from argparse. """ + self._last_focus_object = None + qt_args = qtutils.get_args(args) log.init.debug("Qt arguments: {}, based on {}".format(qt_args, args)) super().__init__(qt_args) @@ -758,7 +761,10 @@ class Application(QApplication): @pyqtSlot(QObject) def on_focus_object_changed(self, obj): """Log when the focus object changed.""" - log.misc.debug("Focus object changed: {!r}".format(obj)) + output = repr(obj) + if self._last_focus_object != output: + log.misc.debug("Focus object changed: {}".format(output)) + self._last_focus_object = output def __repr__(self): return utils.get_repr(self) diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 8d1a1ac1c..8650774c4 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -402,7 +402,10 @@ class WebEngineElements(browsertab.AbstractElements): Called with a WebEngineElement or None. js_elem: The element serialized from javascript. """ - log.webview.debug("Got element from JS: {!r}".format(js_elem)) + debug_str = ('None' if js_elem is None + else utils.elide(repr(js_elem), 100)) + log.webview.debug("Got element from JS: {}".format(debug_str)) + if js_elem is None: callback(None) else: diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index a7083b36a..879013f38 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -559,6 +559,11 @@ class TabbedBrowser(tabwidget.TabWidget): # closing the last tab (before quitting) or shutting down return tab = self.widget(idx) + if tab is None: + log.webview.debug("on_current_changed got called with invalid " + "index {}".format(idx)) + return + log.modes.debug("Current tab changed, focusing {!r}".format(tab)) tab.setFocus() for mode in [usertypes.KeyMode.hint, usertypes.KeyMode.insert, diff --git a/qutebrowser/misc/ipc.py b/qutebrowser/misc/ipc.py index 4f77379d0..4afae78e9 100644 --- a/qutebrowser/misc/ipc.py +++ b/qutebrowser/misc/ipc.py @@ -362,6 +362,9 @@ class IPCServer(QObject): @pyqtSlot() def on_timeout(self): """Cancel the current connection if it was idle for too long.""" + if self._socket is None: + log.ipc.error("on_timeout got called with None socket!") + return log.ipc.error("IPC connection timed out " "(socket 0x{:x}).".format(id(self._socket))) self._socket.disconnectFromServer()