This commit is contained in:
thuck 2016-11-08 19:53:46 +01:00
commit d8b5ca295e
4 changed files with 19 additions and 2 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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,

View File

@ -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()