fix: some users have corrupted preferences, crashing on launch

This commit is contained in:
Louis Pontoise authored and lwouis committed 2020-08-31 14:41:16 +09:00
1 parent 20e474b6f5
commit 30625662a2
2 files changed
+16 -2

No files matched your search

+15
View File
@@ -124,6 +124,21 @@ class Preferences {
static var highlightBackgroundColor: NSColor { theme.themeParameters.highlightBackgroundColor }
static var font: NSFont { NSFont.systemFont(ofSize: fontHeight) }
static func initialize() {
removeCorruptedPreferences()
migratePreferences()
registerDefaults()
}
static func removeCorruptedPreferences() {
// from v5.1.0+, there are crash reports of users somehow having their hold shortcuts set to ""
["holdShortcut", "holdShortcut2"].forEach {
if let s = defaults.string(forKey: $0), s == "" {
defaults.removeObject(forKey: $0)
}
}
}
static func registerDefaults() {
defaults.register(defaults: defaultValues)
}
+1 -2
View File
@@ -44,8 +44,7 @@ class App: AppCenterApplication, NSApplicationDelegate {
SystemPermissions.ensurePermissionsAreGranted { [weak self] in
guard let self = self else { return }
BackgroundWork.start()
Preferences.migratePreferences()
Preferences.registerDefaults()
Preferences.initialize()
Menubar.initialize()
self.loadMainMenuXib()
self.thumbnailsPanel = ThumbnailsPanel()