move .reopen() to mw; fix exporting
This commit is contained in:
parent
fe59d11047
commit
fa12213e98
@ -262,14 +262,6 @@ crt=?, mod=?, scm=?, dty=?, usn=?, ls=?, conf=?""",
|
||||
self.media.close()
|
||||
self._closeLog()
|
||||
|
||||
def reopen(self) -> None:
|
||||
"Reconnect to DB (after changing threads, etc)."
|
||||
raise Exception("fixme")
|
||||
# if not self.db:
|
||||
# # self.db = DBProxy(self.path)
|
||||
# self.media.connect()
|
||||
# self._openLog()
|
||||
|
||||
def rollback(self) -> None:
|
||||
self.db.rollback()
|
||||
self.db.begin()
|
||||
|
@ -397,20 +397,20 @@ class AnkiCollectionPackageExporter(AnkiPackageExporter):
|
||||
AnkiPackageExporter.__init__(self, col)
|
||||
|
||||
def doExport(self, z, path):
|
||||
# close our deck & write it into the zip file, and reopen
|
||||
"Export collection. Caller must re-open afterwards."
|
||||
# close our deck & write it into the zip file
|
||||
self.count = self.col.cardCount()
|
||||
v2 = self.col.schedVer() != 1
|
||||
mdir = self.col.media.dir()
|
||||
self.col.close()
|
||||
if not v2:
|
||||
z.write(self.col.path, "collection.anki2")
|
||||
else:
|
||||
self._addDummyCollection(z)
|
||||
z.write(self.col.path, "collection.anki21")
|
||||
self.col.reopen()
|
||||
# copy all media
|
||||
if not self.includeMedia:
|
||||
return {}
|
||||
mdir = self.col.media.dir()
|
||||
return self._exportMedia(z, os.listdir(mdir), mdir)
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ class ExportDialog(QDialog):
|
||||
):
|
||||
QDialog.__init__(self, mw, Qt.Window)
|
||||
self.mw = mw
|
||||
self.col = mw.col
|
||||
self.col = mw.col.weakref()
|
||||
self.frm = aqt.forms.exporting.Ui_ExportDialog()
|
||||
self.frm.setupUi(self)
|
||||
self.exporter = None
|
||||
@ -151,6 +151,7 @@ class ExportDialog(QDialog):
|
||||
period = 3000
|
||||
if self.isVerbatim:
|
||||
msg = _("Collection exported.")
|
||||
self.mw.reopen()
|
||||
else:
|
||||
if self.isTextNote:
|
||||
msg = (
|
||||
|
@ -459,7 +459,6 @@ close the profile or restart Anki."""
|
||||
|
||||
def _loadCollection(self) -> bool:
|
||||
cpath = self.pm.collectionPath()
|
||||
|
||||
self.col = Collection(cpath)
|
||||
|
||||
self.setEnabled(True)
|
||||
@ -467,6 +466,10 @@ close the profile or restart Anki."""
|
||||
self.moveToState("deckBrowser")
|
||||
return True
|
||||
|
||||
def reopen(self):
|
||||
cpath = self.pm.collectionPath()
|
||||
self.col = Collection(cpath)
|
||||
|
||||
def unloadCollection(self, onsuccess: Callable) -> None:
|
||||
def callback():
|
||||
self.setEnabled(False)
|
||||
|
Loading…
Reference in New Issue
Block a user