Fix completion selection bug.

Fix the issue where pressing `o<esc>o` would show a url completion
dialog where attempting to <Tab> select items would do nothing but show
a Qt warning.

The fix is to ensure we set _last_completion_func to None whenever we
clear completion (there was a case I missed).

It also ensures we always delete the old model and adds a safety to
prevent deleting an in-use model is set_model is called with the current
model.
This commit is contained in:
Ryan Roden-Corrent 2017-06-08 22:27:46 -04:00
parent fa39b82b3c
commit 61a1709141
2 changed files with 7 additions and 5 deletions

View File

@ -211,6 +211,7 @@ class Completer(QObject):
# FIXME complete searches # FIXME complete searches
# https://github.com/qutebrowser/qutebrowser/issues/32 # https://github.com/qutebrowser/qutebrowser/issues/32
completion.set_model(None) completion.set_model(None)
self._last_completion_func = None
return return
before_cursor, pattern, after_cursor = self._partition() before_cursor, pattern, after_cursor = self._partition()

View File

@ -269,17 +269,18 @@ class CompletionView(QTreeView):
Args: Args:
model: The model to use. model: The model to use.
""" """
if self.model() is not None and model is not self.model():
self.model().deleteLater()
self.selectionModel().deleteLater()
self.setModel(model)
if model is None: if model is None:
self._active = False self._active = False
self.hide() self.hide()
return return
if self.model() is not None:
self.model().deleteLater()
self.selectionModel().deleteLater()
model.setParent(self) model.setParent(self)
self.setModel(model)
self._active = True self._active = True
self._maybe_show() self._maybe_show()