Repo // Stablize the static AppDelegate instance.

This commit is contained in:
ShikiSuen 2023-05-18 17:45:39 +08:00
parent c33c50d2d8
commit e9c4f845d6
6 changed files with 7 additions and 5 deletions

View File

@ -15,6 +15,7 @@ import UpdateSputnik
@objc(AppDelegate)
public class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDelegate {
public static let shared = AppDelegate()
private var folderMonitor = FolderMonitor(
url: URL(fileURLWithPath: LMMgr.dataFolderPath(isDefaultFolder: false))
)

View File

@ -292,7 +292,7 @@ public extension SessionCtl {
DispatchQueue.main.async {
UpdateSputnik.shared.checkForUpdate(forced: false, url: kUpdateInfoSourceURL)
(NSApp.delegate as? AppDelegate)?.checkMemoryUsage()
AppDelegate.shared.checkMemoryUsage()
}
state = IMEState.ofEmpty()

View File

@ -363,7 +363,7 @@ public extension SessionCtl {
}
@objc func selfUninstall(_: Any? = nil) {
(NSApp.delegate as? AppDelegate)?.selfUninstall()
AppDelegate.shared.selfUninstall()
}
@objc func selfTerminate(_: Any? = nil) {

View File

@ -86,7 +86,7 @@ struct VwrPrefPaneDictionary: View {
if LMMgr.checkIfSpecifiedUserDataFolderValid(newPath) {
userDataFolderSpecified = newPath
BookmarkManager.shared.saveBookmark(for: url)
(NSApp.delegate as? AppDelegate)?.updateDirectoryMonitorPath()
AppDelegate.shared.updateDirectoryMonitorPath()
} else {
IMEApp.buzz()
if !bolPreviousFolderValidity {

View File

@ -354,7 +354,7 @@ class CtlPrefWindow: NSWindowController, NSWindowDelegate {
if LMMgr.checkIfSpecifiedUserDataFolderValid(newPath) {
PrefMgr.shared.userDataFolderSpecified = newPath
BookmarkManager.shared.saveBookmark(for: url)
(NSApp.delegate as? AppDelegate)?.updateDirectoryMonitorPath()
AppDelegate.shared.updateDirectoryMonitorPath()
} else {
IMEApp.buzz()
if !bolPreviousFolderValidity {

View File

@ -67,7 +67,8 @@ else {
public let theServer = server
public let kUpdateInfoSourceURL = urlUpdateInfoSource
NSApp.run()
NSApplication.shared.delegate = AppDelegate.shared
_ = NSApplicationMain(CommandLine.argc, CommandLine.unsafeArgv)
// MARK: - Top-level Enums relating to Input Mode and Language Supports.