diff --git a/ankiqt/ui/addcards.py b/ankiqt/ui/addcards.py index f5a2cce00..521ea339f 100644 --- a/ankiqt/ui/addcards.py +++ b/ankiqt/ui/addcards.py @@ -175,6 +175,7 @@ question or answer on all cards."""), parent=self) def reject(self): if self.onClose(): + self.modelChooser.deinit() QDialog.reject(self) def onClose(self): diff --git a/ankiqt/ui/cardlist.py b/ankiqt/ui/cardlist.py index 0c7bb89da..42e58322a 100644 --- a/ankiqt/ui/cardlist.py +++ b/ankiqt/ui/cardlist.py @@ -1254,6 +1254,7 @@ class ChangeModelDialog(QDialog): def reject(self): self.parent.deck.currentModel = self.origModel + self.modelChooser.deinit() return QDialog.reject(self) def accept(self): @@ -1269,6 +1270,7 @@ class ChangeModelDialog(QDialog): if self.targetModel == self.oldModel: self.ret = (self.targetModel, None, cmap) return QDialog.accept(self) + self.modelChooser.deinit() self.ret = (self.targetModel, fmap, cmap) return QDialog.accept(self) diff --git a/ankiqt/ui/displayproperties.py b/ankiqt/ui/displayproperties.py index 8f75f337e..8067eb8e1 100644 --- a/ankiqt/ui/displayproperties.py +++ b/ankiqt/ui/displayproperties.py @@ -299,6 +299,7 @@ class DisplayProperties(QDialog): def reject(self): ui.dialogs.close("DisplayProperties") + self.modelChooser.deinit() QDialog.reject(self) def onHelp(self): diff --git a/ankiqt/ui/importing.py b/ankiqt/ui/importing.py index 90e7ce27f..19f36bbfc 100644 --- a/ankiqt/ui/importing.py +++ b/ankiqt/ui/importing.py @@ -152,6 +152,7 @@ class ImportDialog(QDialog): # this fixes a strange bug in sqlite self.parent.deck.s.all("pragma integrity_check") self.parent.reset() + self.modelChooser.deinit() def setupMappingFrame(self): # qt seems to have a bug with adding/removing from a grid, so we add diff --git a/ankiqt/ui/modelchooser.py b/ankiqt/ui/modelchooser.py index 6e902232e..cac4c00ee 100644 --- a/ankiqt/ui/modelchooser.py +++ b/ankiqt/ui/modelchooser.py @@ -57,6 +57,9 @@ class ModelChooser(QHBoxLayout): self.drawCardModels() addHook('guiReset', self.onModelEdited) + def deinit(self): + removeHook('guiReset', self.onModelEdited) + def show(self): for i in range(self.count()): self.itemAt(i).widget().show()