Skip to content

Commit

Permalink
fix sub window engine didn't shut down after window closed. close #123
Browse files Browse the repository at this point in the history
  • Loading branch information
boyan01 committed Jul 27, 2022
1 parent be4ae58 commit f33938c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/desktop_multi_window/macos/Classes/FlutterWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,25 @@ class FlutterWindow: BaseFlutterWindow {
window.titleVisibility = .hidden
window.titlebarAppearsTransparent = true
}
}

extension FlutterWindow: NSWindowDelegate {
func windowWillClose(_ notification: Notification) {
deinit {
debugPrint("release window resource")
window.delegate = nil
if let flutterViewController = window.contentViewController as? FlutterViewController {
flutterViewController.engine.shutDownEngine()
}
window.contentViewController = nil
window.windowController = nil
}
}

extension FlutterWindow: NSWindowDelegate {
func windowWillClose(_ notification: Notification) {
delegate?.onClose(windowId: windowId)
}

func windowShouldClose(_ sender: NSWindow) -> Bool {
delegate?.onClose(windowId: windowId)
return true
}
}

0 comments on commit f33938c

Please sign in to comment.