Skip to content

Commit 88ff0a2

Browse files
authored
Merge pull request #88 from caneeeeee/bugfixes
fix: prevent crash when menu bar icon is disabled
2 parents 7964e97 + 9131854 commit 88ff0a2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

auto-clicker/Services/MenuBarService.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,13 @@ final class MenuBarService {
158158
* nothing is coming up.
159159
*/
160160
static func resetImage() {
161-
if let statusBarButton = self.statusBarItem!.button {
162-
statusBarButton.image = NSImage(systemSymbolName: "cursorarrow.click.badge.clock", accessibilityDescription: "auto clicker")
161+
guard let statusBarItem = self.statusBarItem,
162+
let statusBarButton = statusBarItem.button else {
163+
return
163164
}
165+
166+
statusBarButton.image = NSImage(systemSymbolName: "cursorarrow.click.badge.clock",
167+
accessibilityDescription: "auto clicker")
164168
}
165169

166170
static func changeImageColour(newColor: NSColor) {

0 commit comments

Comments
 (0)