reduce the chances of add-ons preventing collections from loading

https://anki.tenderapp.com/discussions/ankidesktop/39953-sync-fail-with-images#comment_48182205
This commit is contained in:
Damien Elmes 2020-03-26 09:53:15 +10:00
parent 8c80f96314
commit 65b8988817

View file

@ -442,7 +442,7 @@ close the profile or restart Anki."""
def loadCollection(self) -> bool:
try:
return self._loadCollection()
self._loadCollection()
except Exception as e:
showWarning(
tr(TR.ERRORS_UNABLE_OPEN_COLLECTION) + "\n" + traceback.format_exc()
@ -460,15 +460,22 @@ close the profile or restart Anki."""
self.showProfileManager()
return False
def _loadCollection(self) -> bool:
# make sure we don't get into an inconsistent state if an add-on
# has broken the deck browser or the did_load hook
try:
self.maybeEnableUndo()
gui_hooks.collection_did_load(self.col)
self.moveToState("deckBrowser")
except Exception as e:
# dump error to stderr so it gets picked up by errors.py
traceback.print_exc()
return True
def _loadCollection(self):
cpath = self.pm.collectionPath()
self.col = Collection(cpath, backend=self.backend)
self.setEnabled(True)
self.maybeEnableUndo()
gui_hooks.collection_did_load(self.col)
self.moveToState("deckBrowser")
return True
def reopen(self):
cpath = self.pm.collectionPath()