Sfoglia il codice sorgente

vmdata: fix memory leak

osy 1 anno fa
parent
commit
d83fedf6d9
1 ha cambiato i file con 5 aggiunte e 3 eliminazioni
  1. 5 3
      Platform/VMData.swift

+ 5 - 3
Platform/VMData.swift

@@ -214,10 +214,12 @@ import SwiftUI
                 }
             }
             
-            wrapped.onStateChange = { [weak self] in
+            wrapped.onStateChange = { [weak self, weak wrapped] in
                 Task { @MainActor in
-                    self?.state = wrapped.state
-                    self?.screenshot = wrapped.screenshot
+                    if let wrapped = wrapped {
+                        self?.state = wrapped.state
+                        self?.screenshot = wrapped.screenshot
+                    }
                 }
             }
         }