From 1e489325c4129e3c6a51005bddaea3dd7f68bca3 Mon Sep 17 00:00:00 2001 From: Ryan Roden-Corrent Date: Thu, 29 Jun 2017 20:58:15 -0400 Subject: [PATCH] Assert if index is invalid in delete_cur_item. CompletionView already checks the index, so an error here shouldn't happen. --- qutebrowser/completion/models/completionmodel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qutebrowser/completion/models/completionmodel.py b/qutebrowser/completion/models/completionmodel.py index 9eb57fe88..a97af2342 100644 --- a/qutebrowser/completion/models/completionmodel.py +++ b/qutebrowser/completion/models/completionmodel.py @@ -215,10 +215,10 @@ class CompletionModel(QAbstractItemModel): def delete_cur_item(self, index): """Delete the row at the given index.""" + qtutils.ensure_valid(index) parent = index.parent() cat = self._cat_from_idx(parent) - if not cat: - raise cmdexc.CommandError("No category selected") + assert cat, "CompletionView sent invalid index for deletion" self.beginRemoveRows(parent, index.row(), index.row()) cat.delete_cur_item(cat.index(index.row(), 0)) self.endRemoveRows()