From 50ebc0505a0099331c391b04e414f1ffc9a3a00d Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Fri, 20 Sep 2024 08:13:54 -0300 Subject: [PATCH] fix(macos): clear_all_browsing_data segfault with null completionHandler the completionHandler cannot be null: https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata --- .changes/fix-clear-browsing-data-macos.md | 5 +++++ src/wkwebview/mod.rs | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changes/fix-clear-browsing-data-macos.md diff --git a/.changes/fix-clear-browsing-data-macos.md b/.changes/fix-clear-browsing-data-macos.md new file mode 100644 index 000000000..aae36ae33 --- /dev/null +++ b/.changes/fix-clear-browsing-data-macos.md @@ -0,0 +1,5 @@ +--- +"wry": patch +--- + +Fixes `WebView::clear_all_browsing_data` crashing with a segfault on macOS. diff --git a/src/wkwebview/mod.rs b/src/wkwebview/mod.rs index 01a0d3477..5f4f29f6d 100644 --- a/src/wkwebview/mod.rs +++ b/src/wkwebview/mod.rs @@ -1136,7 +1136,7 @@ r#"Object.defineProperty(window, 'ipc', { let store: id = msg_send![config, websiteDataStore]; let all_data_types: id = msg_send![class!(WKWebsiteDataStore), allWebsiteDataTypes]; let date: id = msg_send![class!(NSDate), dateWithTimeIntervalSince1970: 0.0]; - let handler = null::<*const c_void>(); + let handler = block::ConcreteBlock::new(move || {}).copy(); let _: () = msg_send![store, removeDataOfTypes:all_data_types modifiedSince:date completionHandler:handler]; } Ok(())