From f271081012e69321d9cad1f4ebdc6c0193a98d8e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 8 Nov 2016 10:36:40 +0100 Subject: [PATCH 1/4] Handle None-tab in on_current_changed --- qutebrowser/mainwindow/tabbedbrowser.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index 6efec0851..e1a07146a 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -558,6 +558,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, From 57ee378ec5ccb7abde7429248e4fe4300a44ea2f Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 8 Nov 2016 11:07:58 +0100 Subject: [PATCH 2/4] Ignore None-socket in ipc.on_timeout --- qutebrowser/misc/ipc.py | 3 +++ 1 file changed, 3 insertions(+) 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() From 19d31ac201d1762a961e8c2e5ee69032ba3d2fd9 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 8 Nov 2016 11:35:02 +0100 Subject: [PATCH 3/4] Deduplicate "Focus object changed" logging --- qutebrowser/app.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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) From 23e7b3f551f1e0c024658aaf3a279c67950ae15c Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 8 Nov 2016 11:37:47 +0100 Subject: [PATCH 4/4] Elide js element debug string --- qutebrowser/browser/webengine/webenginetab.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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: