Remove cyclic dependency from MarkKeyParser.

Rather than calling modeman.leave directly, modeman hooks into a request_leave
signal that is fired when MarkKeyParser wants to exit mark mode.
This commit is contained in:
Ryan Roden-Corrent 2016-04-14 17:29:43 -04:00
parent 49b2f6e967
commit f4b9573744
3 changed files with 7 additions and 2 deletions

View File

@ -67,9 +67,13 @@ class BaseKeyParser(QObject):
Signals:
keystring_updated: Emitted when the keystring is updated.
arg: New keystring.
request_leave: Emitted to request leaving a mode.
arg 0: Mode to leave.
arg 1: Reason for leaving.
"""
keystring_updated = pyqtSignal(str)
request_leave = pyqtSignal(usertypes.KeyMode, str)
do_log = True
passthrough = False

View File

@ -225,6 +225,7 @@ class ModeManager(QObject):
assert isinstance(mode, usertypes.KeyMode)
assert parser is not None
self._parsers[mode] = parser
parser.request_leave.connect(self.leave)
def enter(self, mode, reason=None, only_if_normal=False):
"""Enter a new mode.

View File

@ -27,7 +27,7 @@ from PyQt5.QtCore import pyqtSlot, Qt
from qutebrowser.utils import message
from qutebrowser.config import config
from qutebrowser.keyinput import keyparser, modeman
from qutebrowser.keyinput import keyparser
from qutebrowser.utils import usertypes, log, objreg, utils
@ -276,6 +276,6 @@ class MarkKeyParser(keyparser.BaseKeyParser):
else:
raise ValueError("{} is not a valid mark mode".format(self._mode))
modeman.leave(self._win_id, self._mode, "valid mark key")
self.request_leave.emit(self._mode, "valid mark key")
return True