display(macOS): fix crash due to error dialog showing on background thread
Fixes #5472
This commit is contained in:
parent
f7c38dc52b
commit
4d26f4a20a
|
@ -146,7 +146,9 @@ extension VMDisplayQemuTerminalWindowController: CSPortDelegate {
|
|||
}
|
||||
|
||||
func port(_ port: CSPort, didError error: String) {
|
||||
showErrorAlert(error)
|
||||
Task { @MainActor in
|
||||
showErrorAlert(error)
|
||||
}
|
||||
}
|
||||
|
||||
func port(_ port: CSPort, didRecieveData data: Data) {
|
||||
|
|
|
@ -204,6 +204,7 @@ class VMDisplayWindowController: NSWindowController, UTMVirtualMachineDelegate {
|
|||
|
||||
// MARK: - Alert
|
||||
|
||||
@MainActor
|
||||
func showErrorAlert(_ message: String, completionHandler handler: ((NSApplication.ModalResponse) -> Void)? = nil) {
|
||||
let alert = NSAlert()
|
||||
alert.alertStyle = .critical
|
||||
|
@ -212,6 +213,7 @@ class VMDisplayWindowController: NSWindowController, UTMVirtualMachineDelegate {
|
|||
alert.beginSheetModal(for: window!, completionHandler: handler)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func showConfirmAlert(_ message: String, confirmHandler handler: (() -> Void)? = nil) {
|
||||
let alert = NSAlert()
|
||||
alert.alertStyle = .informational
|
||||
|
|
Loading…
Reference in New Issue