mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
don't change current deck if custom study fails to create
just a quick fix for now https://anki.tenderapp.com/discussions/ankidesktop/37834-bug-custom-study-session-created-even-when-there-are-no-cards-that-match-selected-criteria
This commit is contained in:
parent
bf93731e49
commit
d5707a6388
1 changed files with 10 additions and 1 deletions
|
@ -22,12 +22,13 @@ TYPE_ALL = 3
|
||||||
|
|
||||||
|
|
||||||
class CustomStudy(QDialog):
|
class CustomStudy(QDialog):
|
||||||
def __init__(self, mw):
|
def __init__(self, mw) -> None:
|
||||||
QDialog.__init__(self, mw)
|
QDialog.__init__(self, mw)
|
||||||
self.mw = mw
|
self.mw = mw
|
||||||
self.deck = self.mw.col.decks.current()
|
self.deck = self.mw.col.decks.current()
|
||||||
self.conf = self.mw.col.decks.getConf(self.deck["conf"])
|
self.conf = self.mw.col.decks.getConf(self.deck["conf"])
|
||||||
self.form = f = aqt.forms.customstudy.Ui_Dialog()
|
self.form = f = aqt.forms.customstudy.Ui_Dialog()
|
||||||
|
self.created_custom_study = False
|
||||||
f.setupUi(self)
|
f.setupUi(self)
|
||||||
self.setWindowModality(Qt.WindowModal)
|
self.setWindowModality(Qt.WindowModal)
|
||||||
self.setupSignals()
|
self.setupSignals()
|
||||||
|
@ -179,11 +180,19 @@ class CustomStudy(QDialog):
|
||||||
# add deck limit
|
# add deck limit
|
||||||
dyn["terms"][0][0] = 'deck:"%s" %s ' % (self.deck["name"], dyn["terms"][0][0])
|
dyn["terms"][0][0] = 'deck:"%s" %s ' % (self.deck["name"], dyn["terms"][0][0])
|
||||||
# generate cards
|
# generate cards
|
||||||
|
self.created_custom_study = True
|
||||||
if not self.mw.col.sched.rebuildDyn():
|
if not self.mw.col.sched.rebuildDyn():
|
||||||
return showWarning(_("No cards matched the criteria you provided."))
|
return showWarning(_("No cards matched the criteria you provided."))
|
||||||
self.mw.moveToState("overview")
|
self.mw.moveToState("overview")
|
||||||
QDialog.accept(self)
|
QDialog.accept(self)
|
||||||
|
|
||||||
|
def reject(self) -> None:
|
||||||
|
if self.created_custom_study:
|
||||||
|
# set the original deck back to current
|
||||||
|
self.mw.col.decks.select(self.deck['id'])
|
||||||
|
# fixme: clean up the empty custom study deck
|
||||||
|
QDialog.reject(self)
|
||||||
|
|
||||||
def _getTags(self):
|
def _getTags(self):
|
||||||
from aqt.taglimit import TagLimit
|
from aqt.taglimit import TagLimit
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue