[bugfix] enhanced emergency reset loop for corrupted QSettings

This commit is contained in:
Marcel Paffrath 2018-08-16 16:21:28 +02:00
parent 6546f8f196
commit c23bbfae8a

View File

@ -155,6 +155,9 @@ class MainWindow(QMainWindow):
self.data._new = False
self.autodata = Data(self)
self.fnames = None
self._stime = None
while True:
try:
if settings.value("user/FullName", None) is None:
@ -166,23 +169,6 @@ class MainWindow(QMainWindow):
"Enter authority/institution name:",
"Authority")
settings.setValue("agency_id", agency)
break
except Exception as e:
qmb = QMessageBox(self, icon=QMessageBox.Question,
text='Could not init application settings: {}.'
'Do you want to reset application settings?'.format(e),
windowTitle='PyLoT - Init QSettings warning')
qmb.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
qmb.setDefaultButton(QMessageBox.No)
ret = qmb.exec_()
if ret == qmb.Yes:
settings.clear()
else:
sys.exit()
print('Settings cleared!')
self.fnames = None
self._stime = None
structure_setting = settings.value("data/Structure", "PILOT")
if not structure_setting:
structure_setting = 'PILOT'
@ -204,6 +190,20 @@ class MainWindow(QMainWindow):
if settings.value('autoFilter', None) is None:
settings.setValue('autoFilter', True)
settings.sync()
break
except Exception as e:
qmb = QMessageBox(self, icon=QMessageBox.Question,
text='Could not init application settings: {}.'
'Do you want to reset application settings?'.format(e),
windowTitle='PyLoT - Init QSettings warning')
qmb.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
qmb.setDefaultButton(QMessageBox.No)
ret = qmb.exec_()
if ret == qmb.Yes:
settings.clear()
else:
sys.exit()
print('Settings cleared!')
# setup UI
self.setupUi()