From 9d747a99c9e74b133bbbcced3da30ec96ed79496 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 27 May 2024 11:34:14 -0700 Subject: [PATCH] Make add-feed work again. --- .../IndeterminateProgressWindowController.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Core/Sources/CoreResources/AppKit/IndeterminateProgressWindowController.swift b/Core/Sources/CoreResources/AppKit/IndeterminateProgressWindowController.swift index 8c1dc27c9..95b53f2b0 100644 --- a/Core/Sources/CoreResources/AppKit/IndeterminateProgressWindowController.swift +++ b/Core/Sources/CoreResources/AppKit/IndeterminateProgressWindowController.swift @@ -22,6 +22,7 @@ private final class IndeterminateProgressController { static var windowController: IndeterminateProgressWindowController? static var runningProgressWindow = false + static var modalSession: NSApplication.ModalSession? static func beginProgressWithMessage(_ message: String) { @@ -32,7 +33,10 @@ private final class IndeterminateProgressController { runningProgressWindow = true windowController = IndeterminateProgressWindowController(message: message) - NSApplication.shared.runModal(for: windowController!.window!) + + assert(modalSession == nil) + modalSession = NSApplication.shared.beginModalSession(for: windowController!.window!) + NSApplication.shared.runModalSession(modalSession!) } static func endProgress() { @@ -43,9 +47,15 @@ private final class IndeterminateProgressController { } runningProgressWindow = false - NSApplication.shared.stopModal() + if let modalSession { + NSApplication.shared.endModalSession(modalSession) + } else { + assertionFailure("endProgress called without a modalSession.") + } + windowController?.close() windowController = nil + modalSession = nil } }