From 096e700a8ca927cb5ab5bb0bd19246fab581246b Mon Sep 17 00:00:00 2001 From: Alexey Martemyanov Date: Mon, 24 Jun 2024 17:08:04 +0700 Subject: [PATCH] fix crash on quit right after launch (#2896) Task/Issue URL: https://app.asana.com/0/1201048563534612/1207629503281977/f Sentry URL: https://errors.duckduckgo.com/organizations/ddg/issues/23562/events/20f7de362f1711efad0e85bf8f8f9cca/?project=6 --- DuckDuckGo/Application/AppDelegate.swift | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/DuckDuckGo/Application/AppDelegate.swift b/DuckDuckGo/Application/AppDelegate.swift index 5d5d2fbe6c..6f0928275e 100644 --- a/DuckDuckGo/Application/AppDelegate.swift +++ b/DuckDuckGo/Application/AppDelegate.swift @@ -636,13 +636,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } } + @MainActor private func setUpAutoClearHandler() { - DispatchQueue.main.async { - self.autoClearHandler = AutoClearHandler(preferences: .shared, + let autoClearHandler = AutoClearHandler(preferences: .shared, fireViewModel: FireCoordinator.fireViewModel, - stateRestorationManager: self.stateRestorationManager) - self.autoClearHandler.handleAppLaunch() - self.autoClearHandler.onAutoClearCompleted = { + stateRestorationManager: self.stateRestorationManager) + self.autoClearHandler = autoClearHandler + DispatchQueue.main.async { + autoClearHandler.handleAppLaunch() + autoClearHandler.onAutoClearCompleted = { NSApplication.shared.reply(toApplicationShouldTerminate: true) } }