From d83cdc076bc55953317ab83964c4762ed4d6de40 Mon Sep 17 00:00:00 2001 From: Dustin Hilgaertner Date: Fri, 3 Apr 2026 23:38:26 -0500 Subject: [PATCH] Fix crash when reopening About or Settings window (#42) NSWindow defaults to isReleasedWhenClosed=true, which deallocates the window when closed. The stored reference then points to a released object, causing a crash on the next open. Set isReleasedWhenClosed=false and reuse the existing window instance instead of recreating it. Co-Authored-By: Claude Opus 4.6 (1M context) --- Sources/Crow/App/AppDelegate.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sources/Crow/App/AppDelegate.swift b/Sources/Crow/App/AppDelegate.swift index 5814ce2..4590141 100644 --- a/Sources/Crow/App/AppDelegate.swift +++ b/Sources/Crow/App/AppDelegate.swift @@ -260,7 +260,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { } @objc private func showAbout() { - if let existing = aboutWindow, existing.isVisible { + if let existing = aboutWindow { existing.makeKeyAndOrderFront(nil) return } @@ -274,6 +274,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { ) win.title = "About Crow" win.appearance = NSAppearance(named: .darkAqua) + win.isReleasedWhenClosed = false win.contentView = hostingView win.center() win.makeKeyAndOrderFront(nil) @@ -283,7 +284,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { @objc private func showSettings() { guard let devRoot, let appConfig else { return } - if let existing = settingsWindow, existing.isVisible { + if let existing = settingsWindow { existing.makeKeyAndOrderFront(nil) return } @@ -309,6 +310,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate { ) win.title = "Settings" win.appearance = NSAppearance(named: .darkAqua) + win.isReleasedWhenClosed = false win.contentView = hostingView win.center() win.makeKeyAndOrderFront(nil)