Work around userscript crash issue

This commit is contained in:
Florian Bruhin 2017-06-11 13:17:00 +02:00
parent 89218c9d31
commit 73ff2afb3f
2 changed files with 10 additions and 0 deletions

View File

@ -130,6 +130,7 @@ Fixed
- (QtWebEngine) HTML fullscreen is now tracked for each tab separately, which
means it's not possible anymore to accidentally get stuck in fullscreen state
by closing a tab with a fullscreen video.
- For some people, running some userscripts crashed - this should now be fixed.
- Various other rare crashes should now be fixed.
- The settings documentation was truncated with v0.10.1 which should now be
fixed.

View File

@ -40,6 +40,7 @@ class _QtFIFOReader(QObject):
_filepath: The path to the opened FIFO.
_fifo: The Python file object for the FIFO.
_notifier: The QSocketNotifier used.
_finished: Set after cleanup() has been called.
Signals:
got_line: Emitted when a whole line arrived.
@ -59,11 +60,18 @@ class _QtFIFOReader(QObject):
self._fifo = os.fdopen(fd, 'r')
self._notifier = QSocketNotifier(fd, QSocketNotifier.Read, self)
self._notifier.activated.connect(self.read_line)
self._finished = False
@pyqtSlot()
def read_line(self):
"""(Try to) read a line from the FIFO."""
log.procs.debug("QSocketNotifier triggered!")
if self._finished:
# For unknown reasons, read_line can still get called after
# cleanup() was, and the QSocketNotifier was already deleted...
log.procs.debug("QtFIFOReader finished already...")
return
self._notifier.setEnabled(False)
try:
for line in self._fifo:
@ -75,6 +83,7 @@ class _QtFIFOReader(QObject):
def cleanup(self):
"""Clean up so the FIFO can be closed."""
self._finished = True
self._notifier.setEnabled(False)
for line in self._fifo:
self.got_line.emit(line.rstrip('\r\n'))