fix failure to start on new install - lang init needs to be deferred

This commit is contained in:
Damien Elmes 2019-12-24 20:23:36 +10:00
parent 06e917f80b
commit 9767b6b8a5
3 changed files with 7 additions and 5 deletions

View File

@ -392,12 +392,14 @@ environment points to a valid, writable folder.""",
) )
return return
if pmLoadResult.firstTime:
pm.setDefaultLang()
if pmLoadResult.loadError: if pmLoadResult.loadError:
QMessageBox.warning( QMessageBox.warning(
None, None,
"Preferences Corrupt", "Preferences Corrupt",
"""\ """Anki's prefs21.db file was corrupt and has been recreated. If you were using multiple \
Anki's prefs21.db file was corrupt and has been recreated. If you were using multiple \
profiles, please add them back using the same names to recover your cards.""", profiles, please add them back using the same names to recover your cards.""",
) )

View File

@ -385,7 +385,6 @@ create table if not exists profiles
"insert or replace into profiles values ('_global', ?)", "insert or replace into profiles values ('_global', ?)",
self._pickle(metaConf), self._pickle(metaConf),
) )
self._setDefaultLang()
return result return result
def _ensureProfile(self): def _ensureProfile(self):
@ -409,7 +408,7 @@ please see:
###################################################################### ######################################################################
# On first run, allow the user to choose the default language # On first run, allow the user to choose the default language
def _setDefaultLang(self): def setDefaultLang(self):
# create dialog # create dialog
class NoCloseDiag(QDialog): class NoCloseDiag(QDialog):
def reject(self): def reject(self):
@ -452,7 +451,7 @@ please see:
None, "Anki", en % name, QMessageBox.Yes | QMessageBox.No, QMessageBox.No None, "Anki", en % name, QMessageBox.Yes | QMessageBox.No, QMessageBox.No
) )
if r != QMessageBox.Yes: if r != QMessageBox.Yes:
return self._setDefaultLang() return self.setDefaultLang()
self.setLang(code) self.setLang(code)
def setLang(self, code): def setLang(self, code):

View File

@ -417,6 +417,7 @@ body {{ zoom: {}; background: {}; {} }}
def _onHeight(self, qvar): def _onHeight(self, qvar):
from aqt import mw from aqt import mw
if qvar is None: if qvar is None:
mw.progress.timer(1000, mw.reset, False) mw.progress.timer(1000, mw.reset, False)