Skip to content

Commit 94d5903

Browse files
committed
fix(macos): Fix app will crash when closing the tray. #44
1 parent 89aa700 commit 94d5903

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

macos/Classes/TrayManagerPlugin.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,14 @@ public class TrayManagerPlugin: NSObject, FlutterPlugin, NSMenuDelegate {
104104
}
105105

106106
public func destroy(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
107-
if (trayIcon == nil) {
108-
result(true)
109-
} else {
107+
if (trayIcon?.statusItem != nil) {
110108
NSStatusBar.system.removeStatusItem((trayIcon?.statusItem)!)
109+
}
110+
if (trayIcon != nil) {
111111
trayIcon?.removeImage()
112112
trayIcon = nil
113-
result(true)
114113
}
114+
result(true)
115115
}
116116

117117
public func getBounds(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
@@ -170,7 +170,7 @@ public class TrayManagerPlugin: NSObject, FlutterPlugin, NSMenuDelegate {
170170

171171
result(true)
172172
}
173-
173+
174174
public func setToolTip(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
175175
let args:[String: Any] = call.arguments as! [String: Any]
176176
let toolTip: String = args["toolTip"] as! String;

0 commit comments

Comments
 (0)