Skip to content

Commit f33938c

Browse files
committed
fix sub window engine didn't shut down after window closed. close MixinNetwork#123
1 parent be4ae58 commit f33938c

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

packages/desktop_multi_window/macos/Classes/FlutterWindow.swift

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,25 @@ class FlutterWindow: BaseFlutterWindow {
7979
window.titleVisibility = .hidden
8080
window.titlebarAppearsTransparent = true
8181
}
82-
}
8382

84-
extension FlutterWindow: NSWindowDelegate {
85-
func windowWillClose(_ notification: Notification) {
83+
deinit {
84+
debugPrint("release window resource")
8685
window.delegate = nil
86+
if let flutterViewController = window.contentViewController as? FlutterViewController {
87+
flutterViewController.engine.shutDownEngine()
88+
}
8789
window.contentViewController = nil
8890
window.windowController = nil
91+
}
92+
}
93+
94+
extension FlutterWindow: NSWindowDelegate {
95+
func windowWillClose(_ notification: Notification) {
96+
delegate?.onClose(windowId: windowId)
97+
}
98+
99+
func windowShouldClose(_ sender: NSWindow) -> Bool {
89100
delegate?.onClose(windowId: windowId)
101+
return true
90102
}
91103
}

0 commit comments

Comments
 (0)