From 2adc821a679bf88293b3fcb940e3a9d317441717 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 6 Feb 2022 12:00:16 +0530 Subject: [PATCH] ... --- src/calibre/gui2/dialogs/tag_editor.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calibre/gui2/dialogs/tag_editor.py b/src/calibre/gui2/dialogs/tag_editor.py index 077d0cba97..030cf34977 100644 --- a/src/calibre/gui2/dialogs/tag_editor.py +++ b/src/calibre/gui2/dialogs/tag_editor.py @@ -196,9 +196,10 @@ class TagEditor(QDialog, Ui_TagEditor): tag = tag.strip() if not tag: continue - for index in self.all_tags_model.match(self.all_tags_model.index(0), Qt.ItemDataRole.DisplayRole, tag, -1, - Qt.MatchFlag.MatchFixedString | Qt.MatchFlag.MatchCaseSensitive | Qt.MatchFlag.MatchWrap): - self.all_tags_model.removeRow(index.row()) + if self.all_tags_model.rowCount(): + for index in self.all_tags_model.match(self.all_tags_model.index(0), Qt.ItemDataRole.DisplayRole, tag, -1, + Qt.MatchFlag.MatchFixedString | Qt.MatchFlag.MatchCaseSensitive | Qt.MatchFlag.MatchWrap): + self.all_tags_model.removeRow(index.row()) if tag not in tags_in_box: tags_in_box.append(tag)