Skip to content

Commit

Permalink
Fix closing full-screen videos with the X button
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed May 9, 2024
1 parent 567c062 commit a17ede4
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions DuckDuckGo/Tab/View/WebViewContainerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,21 +141,22 @@ final class WebViewContainerView: NSView {
}
.store(in: &cancellables)

fullScreenWindowWillCloseCancellable = NotificationCenter.default.publisher(for: NSWindow.willCloseNotification, object: fullScreenWindow)
.sink { [weak self] notification in
self?.fullScreenWindowWillCloseCancellable = nil
let fullScreenWindowController = (notification.object as? NSWindow)?.windowController
DispatchQueue.main.async { [weak fullScreenWindowController] in
guard let fullScreenWindowController else { return }
// just in case.
// if WKFullScreenWindowController receives `close()` the next time it‘s open it will crash because its _webView is nil
// https://errors.duckduckgo.com/organizations/ddg/issues/3411/?project=6&referrer=release-issue-stream
NSException.try {
fullScreenWindowController.setValue(NSView(), forKeyPath: #keyPath(webView))
if #unavailable(macOS 14.4) {
fullScreenWindowWillCloseCancellable = NotificationCenter.default.publisher(for: NSWindow.willCloseNotification, object: fullScreenWindow)
.sink { [weak self] notification in
self?.fullScreenWindowWillCloseCancellable = nil
let fullScreenWindowController = (notification.object as? NSWindow)?.windowController
DispatchQueue.main.async { [weak fullScreenWindowController] in
guard let fullScreenWindowController else { return }
// just in case.
// if WKFullScreenWindowController receives `close()` the next time it‘s open it will crash because its _webView is nil
// https://errors.duckduckgo.com/organizations/ddg/issues/3411/?project=6&referrer=release-issue-stream
NSException.try {
fullScreenWindowController.setValue(NSView(), forKeyPath: #keyPath(webView))
}
}

}
}
}

}

Expand Down

0 comments on commit a17ede4

Please sign in to comment.