Fix bug (crashes on systems with pyqt < 5.3)

Crash occurs in usertypes.py / Question class due to Python slots
being called on deleted Qt objects. This causes either a TypeError or
an AttributeError (probably depending on the state of the deleted Qt
object?).

Fixed by declaring slots in the Question object explicitly via
decorator "@pyqtSlot()".

Possible further TODOs:
- Find out whether this is a problem for slots in other objects as
  well.
- Create unittest for this bug (might me somewhat tricky, though).
This commit is contained in:
Andreas Fischer 2015-01-07 23:40:48 +01:00
parent 77df4c7241
commit 34c9a73e32

View File

@ -27,7 +27,7 @@ import operator
import collections.abc import collections.abc
import enum as pyenum import enum as pyenum
from PyQt5.QtCore import pyqtSignal, QObject, QTimer from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, QTimer
from qutebrowser.utils import log, qtutils, utils from qutebrowser.utils import log, qtutils, utils
@ -307,6 +307,7 @@ class Question(QObject):
raise TypeError("Mode {} is no PromptMode member!".format(val)) raise TypeError("Mode {} is no PromptMode member!".format(val))
self._mode = val self._mode = val
@pyqtSlot()
def done(self): def done(self):
"""Must be called when the queston was answered completely.""" """Must be called when the queston was answered completely."""
self.answered.emit(self.answer) self.answered.emit(self.answer)
@ -317,11 +318,13 @@ class Question(QObject):
self.answered_no.emit() self.answered_no.emit()
self.completed.emit() self.completed.emit()
@pyqtSlot()
def cancel(self): def cancel(self):
"""Cancel the question (resulting from user-input).""" """Cancel the question (resulting from user-input)."""
self.cancelled.emit() self.cancelled.emit()
self.completed.emit() self.completed.emit()
@pyqtSlot()
def abort(self): def abort(self):
"""Abort the question.""" """Abort the question."""
self.is_aborted = True self.is_aborted = True