kopia lustrzana https://github.com/corrscope/corrscope
Fix longstanding crash when prefs.yaml is corrupted
Instead, warn the user with a popup dialog, and reset settings to default. Every few months, a user would report corrscope failing to open due to a corrupted prefs.yaml. This commit should stop all occurrences of that from now on. The next commit will help ensure that we never save corrupted files in the first place.pull/377/head
rodzic
f80730ffd7
commit
9b97221001
|
@ -175,7 +175,14 @@ class MainWindow(qw.QMainWindow, Ui_MainWindow):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
# Load settings.
|
# Load settings.
|
||||||
self.pref = gp.load_prefs()
|
prefs_error = None
|
||||||
|
try:
|
||||||
|
self.pref = gp.load_prefs()
|
||||||
|
if not isinstance(self.pref, gp.GlobalPrefs):
|
||||||
|
raise TypeError(f"prefs.yaml contains wrong type {type(self.pref)}")
|
||||||
|
except Exception as e:
|
||||||
|
prefs_error = e
|
||||||
|
self.pref = gp.GlobalPrefs()
|
||||||
|
|
||||||
# Load UI.
|
# Load UI.
|
||||||
self.setupUi(self) # sets windowTitle
|
self.setupUi(self) # sets windowTitle
|
||||||
|
@ -237,6 +244,12 @@ class MainWindow(qw.QMainWindow, Ui_MainWindow):
|
||||||
|
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
|
if prefs_error is not None:
|
||||||
|
TracebackDialog(self).showMessage(
|
||||||
|
"Warning: failed to load global preferences, resetting to default.\n"
|
||||||
|
+ format_stack_trace(prefs_error)
|
||||||
|
)
|
||||||
|
|
||||||
_cfg_path: Optional[Path]
|
_cfg_path: Optional[Path]
|
||||||
|
|
||||||
# Whether document is dirty, changed, has unsaved changes
|
# Whether document is dirty, changed, has unsaved changes
|
||||||
|
|
Ładowanie…
Reference in New Issue