From c9174c6a2e9da7c8b2db64f23b81abbb87a2ec62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rob=20Mulder=20=EF=A3=BF?= Date: Fri, 13 Mar 2026 09:43:36 +0100 Subject: [PATCH] Fix: resolve memory leaks and remove debug info leakage --- LauncherApplication/AppDelegate.swift | 2 +- .../Preferences/PreferencesViewController.swift | 4 ++++ hidden/Features/StatusBar/StatusBarController.swift | 10 +++++----- hidden/Models/GlobalKeybindingPreferences.swift | 1 - 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/LauncherApplication/AppDelegate.swift b/LauncherApplication/AppDelegate.swift index c58a0bf..400d6e6 100644 --- a/LauncherApplication/AppDelegate.swift +++ b/LauncherApplication/AppDelegate.swift @@ -42,7 +42,7 @@ class AppDelegate: NSObject, NSApplicationDelegate { } func applicationWillTerminate(_ aNotification: Notification) { - // Insert code here to tear down your application + DistributedNotificationCenter.default().removeObserver(self) } diff --git a/hidden/Features/Preferences/PreferencesViewController.swift b/hidden/Features/Preferences/PreferencesViewController.swift index 1703cd2..c51145e 100644 --- a/hidden/Features/Preferences/PreferencesViewController.swift +++ b/hidden/Features/Preferences/PreferencesViewController.swift @@ -47,6 +47,10 @@ class PreferencesViewController: NSViewController { } } + deinit { + NotificationCenter.default.removeObserver(self) + } + //MARK: - VC Life cycle override func viewDidLoad() { super.viewDidLoad() diff --git a/hidden/Features/StatusBar/StatusBarController.swift b/hidden/Features/StatusBar/StatusBarController.swift index 1d17718..822c63f 100644 --- a/hidden/Features/StatusBar/StatusBarController.swift +++ b/hidden/Features/StatusBar/StatusBarController.swift @@ -67,9 +67,9 @@ class StatusBarController { setupUI() setupAlwayHideStatusBar() NotificationCenter.default.addObserver(self, selector: #selector(handleScreenParametersChanged), name: NSApplication.didChangeScreenParametersNotification, object: nil) - DispatchQueue.main.asyncAfter(deadline: .now() + 1, execute: { - self.collapseMenuBar() - }) + DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in + self?.collapseMenuBar() + } if Preferences.areSeparatorsHidden {hideSeparators()} autoCollapseIfNeeded() @@ -157,8 +157,8 @@ class StatusBarController { if isToggle {return} isToggle = true self.isCollapsed ? self.expandMenubar() : self.collapseMenuBar() - DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { - self.isToggle = false + DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in + self?.isToggle = false } } diff --git a/hidden/Models/GlobalKeybindingPreferences.swift b/hidden/Models/GlobalKeybindingPreferences.swift index ebf6b14..8ea1120 100644 --- a/hidden/Models/GlobalKeybindingPreferences.swift +++ b/hidden/Models/GlobalKeybindingPreferences.swift @@ -20,7 +20,6 @@ struct GlobalKeybindPreferences: Codable, CustomStringConvertible { let keyCode : UInt32 var description: String { - print(keyCode) var stringBuilder = "" if self.function { stringBuilder += "Fn"