Skip to content

Commit e3baf97

Browse files
authored
fix: remove the IPC message handler only if it is registered/owned by the popup
1 parent 633156f commit e3baf97

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/wkwebview/mod.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,12 +1400,14 @@ impl Drop for InnerWebView {
14001400
// We need to drop handler closures here
14011401
unsafe {
14021402
if let Some(ipc_handler) = self.ipc_handler_delegate.take() {
1403-
let ipc = ns_string!(IPC_MESSAGE_HANDLER_NAME);
1404-
// this will decrease the retain count of the ipc handler and trigger the drop
1405-
ipc_handler
1406-
.ivars()
1407-
.controller
1408-
.removeScriptMessageHandlerForName(ipc);
1403+
if ipc_handler.ivars().registered_ipc_handler.get() {
1404+
let ipc = ns_string!(IPC_MESSAGE_HANDLER_NAME);
1405+
// this will decrease the retain count of the ipc handler and trigger the drop
1406+
ipc_handler
1407+
.ivars()
1408+
.controller
1409+
.removeScriptMessageHandlerForName(ipc);
1410+
}
14091411
}
14101412

14111413
// Remove webview from window's NSView before dropping.

0 commit comments

Comments
 (0)