[bugfix] enhanced emergency reset loop for corrupted QSettings
This commit is contained in:
parent
6546f8f196
commit
c23bbfae8a
34
PyLoT.py
34
PyLoT.py
@ -155,6 +155,9 @@ class MainWindow(QMainWindow):
|
|||||||
self.data._new = False
|
self.data._new = False
|
||||||
self.autodata = Data(self)
|
self.autodata = Data(self)
|
||||||
|
|
||||||
|
self.fnames = None
|
||||||
|
self._stime = None
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
if settings.value("user/FullName", None) is None:
|
if settings.value("user/FullName", None) is None:
|
||||||
@ -166,23 +169,6 @@ class MainWindow(QMainWindow):
|
|||||||
"Enter authority/institution name:",
|
"Enter authority/institution name:",
|
||||||
"Authority")
|
"Authority")
|
||||||
settings.setValue("agency_id", agency)
|
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")
|
structure_setting = settings.value("data/Structure", "PILOT")
|
||||||
if not structure_setting:
|
if not structure_setting:
|
||||||
structure_setting = 'PILOT'
|
structure_setting = 'PILOT'
|
||||||
@ -204,6 +190,20 @@ class MainWindow(QMainWindow):
|
|||||||
if settings.value('autoFilter', None) is None:
|
if settings.value('autoFilter', None) is None:
|
||||||
settings.setValue('autoFilter', True)
|
settings.setValue('autoFilter', True)
|
||||||
settings.sync()
|
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
|
# setup UI
|
||||||
self.setupUi()
|
self.setupUi()
|
||||||
|
Loading…
Reference in New Issue
Block a user