From 634ffb4c5797d25932037cb605a449a512326884 Mon Sep 17 00:00:00 2001 From: Nico Verbruggen Date: Thu, 17 Feb 2022 19:23:23 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=20Preparing=20for=20additional=20r?= =?UTF-8?q?efactoring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- phpmon/Common/Helpers/Alert.swift | 5 ++++- phpmon/Domain/Notice/BetterAlert.swift | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/phpmon/Common/Helpers/Alert.swift b/phpmon/Common/Helpers/Alert.swift index 963eb7d..ccc6f7d 100644 --- a/phpmon/Common/Helpers/Alert.swift +++ b/phpmon/Common/Helpers/Alert.swift @@ -7,7 +7,9 @@ import Cocoa -@available(*, deprecated, message: "Use BetterAlert API instead for 5.1 and above") +#warning("This deprecated class should be removed at the earliest convenience once no code relies on it.") + +@available(*, deprecated, message: "Use the BetterAlert API instead") class Alert { public static func present( @@ -17,6 +19,7 @@ class Alert { secondButtonTitle: String = "", style: NSAlert.Style = .informational ) -> Bool { + if !Thread.isMainThread { fatalError("You should always present alerts on the main thread!") } diff --git a/phpmon/Domain/Notice/BetterAlert.swift b/phpmon/Domain/Notice/BetterAlert.swift index 9910aaa..7ba51ef 100644 --- a/phpmon/Domain/Notice/BetterAlert.swift +++ b/phpmon/Domain/Notice/BetterAlert.swift @@ -82,6 +82,7 @@ class BetterAlert { If you wish to simply show the alert and disregard the outcome, use `show`. */ public func runModal() -> NSApplication.ModalResponse { + #warning("You should be alerted if this is not being called on the main thread.") NSApp.activate(ignoringOtherApps: true) windowController.window?.makeKeyAndOrderFront(nil) return NSApplication.shared.runModal(for: windowController.window!)