fix: rare crash at launch if the app previously crashed
This commit is contained in:
1 parent
6505ca5a39
commit
6444732bc5
1 file changed
+11
-2
@@ -12,9 +12,8 @@ class AppCenterCrash: NSObject, MSCrashesDelegate {
|
|||||||
// MSAppCenter.setLogLevel(MSLogLevel.none)
|
// MSAppCenter.setLogLevel(MSLogLevel.none)
|
||||||
MSAppCenter.start(AppCenterCrash.secret, withServices: [MSCrashes.self])
|
MSAppCenter.start(AppCenterCrash.secret, withServices: [MSCrashes.self])
|
||||||
MSCrashes.setDelegate(self)
|
MSCrashes.setDelegate(self)
|
||||||
// when the app starts, this code can execute before defaults are set; we pre-set this default in case
|
|
||||||
defaults.register(defaults: ["crashPolicy": "1"])
|
|
||||||
MSCrashes.setUserConfirmationHandler({ (errorReports: [MSErrorReport]) in
|
MSCrashes.setUserConfirmationHandler({ (errorReports: [MSErrorReport]) in
|
||||||
|
self.initNecessaryFacilities()
|
||||||
if Preferences.crashPolicy == .ask {
|
if Preferences.crashPolicy == .ask {
|
||||||
App.app.activate(ignoringOtherApps: true)
|
App.app.activate(ignoringOtherApps: true)
|
||||||
let alert = NSAlert()
|
let alert = NSAlert()
|
||||||
@@ -40,6 +39,16 @@ class AppCenterCrash: NSObject, MSCrashesDelegate {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// at launch, the crash report handler can be called before some things are not yet ready; we ensure they are
|
||||||
|
func initNecessaryFacilities() {
|
||||||
|
if defaults.string(forKey: "crashPolicy") == nil {
|
||||||
|
defaults.register(defaults: ["crashPolicy": "1"])
|
||||||
|
}
|
||||||
|
if BackgroundWork.crashReportsQueue == nil {
|
||||||
|
BackgroundWork.crashReportsQueue = DispatchQueue.globalConcurrent("crashReportsQueue", .utility)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func crashButtonIdToUpdate(_ userChoice: NSApplication.ModalResponse, _ checkbox: NSButton) -> Int {
|
func crashButtonIdToUpdate(_ userChoice: NSApplication.ModalResponse, _ checkbox: NSButton) -> Int {
|
||||||
if userChoice == .alertFirstButtonReturn {
|
if userChoice == .alertFirstButtonReturn {
|
||||||
if checkbox.state == .on {
|
if checkbox.state == .on {
|
||||||
|
|||||||
Reference in new issue
Block a user