Forráskód Böngészése

display(apple): fix crash when window is closed

Fixes #5347
osy 2 éve
szülő
commit
95a77db0ce
1 módosított fájl, 8 hozzáadás és 5 törlés
  1. 8 5
      Managers/UTMAppleVirtualMachine.swift

+ 8 - 5
Managers/UTMAppleVirtualMachine.swift

@@ -163,13 +163,16 @@ import Virtualization
     }
     }
     
     
     override func vmStop(force: Bool) async throws {
     override func vmStop(force: Bool) async throws {
+        if let installProgress = installProgress {
+            installProgress.cancel()
+            return
+        }
+        guard state == .vmStarted || state == .vmPaused else {
+            return
+        }
         changeState(.vmStopping)
         changeState(.vmStopping)
         do {
         do {
-            if let installProgress = installProgress {
-                installProgress.cancel()
-            } else {
-                try await _vmStop(force: force)
-            }
+            try await _vmStop(force: force)
             changeState(.vmStopped)
             changeState(.vmStopped)
         } catch {
         } catch {
             changeState(.vmStopped)
             changeState(.vmStopped)