catch more problems with corrupt collections

if collapseTime is missing from col.conf, the initial load was
succeeding, but then the UI was getting stuck in moveToState()
This commit is contained in:
Damien Elmes 2018-02-05 12:15:57 +10:00
parent e7046ba398
commit 275af7e9b5

View file

@ -319,9 +319,8 @@ close the profile or restart Anki."""))
########################################################################## ##########################################################################
def loadCollection(self): def loadCollection(self):
cpath = self.pm.collectionPath()
try: try:
self.col = Collection(cpath, log=True) return self._loadCollection()
except Exception as e: except Exception as e:
showWarning(_("""\ showWarning(_("""\
Anki was unable to open your collection file. If problems persist after \ Anki was unable to open your collection file. If problems persist after \
@ -330,9 +329,23 @@ manager.
Debug info: Debug info:
""")+traceback.format_exc()) """)+traceback.format_exc())
# clean up open collection if possible
if self.col:
try:
self.col.close(save=False)
except:
pass
self.col = None
# return to profile manager
self.showProfileManager() self.showProfileManager()
return False return False
def _loadCollection(self):
cpath = self.pm.collectionPath()
self.col = Collection(cpath, log=True)
self.setEnabled(True) self.setEnabled(True)
self.progress.setupDB(self.col.db) self.progress.setupDB(self.col.db)
self.maybeEnableUndo() self.maybeEnableUndo()