From 58dbfc6d7513cdbb12a8243efce26537c8a71da1 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Wed, 4 Feb 2026 10:34:49 -0300 Subject: [PATCH] use debug_cell --- Cargo.lock | 19 +++++++++++++------ crates/tauri-runtime-cef/Cargo.toml | 1 + crates/tauri-runtime-cef/src/cef_impl.rs | 6 +++--- .../src/cef_impl/request_handler.rs | 2 +- crates/tauri-runtime-cef/src/lib.rs | 13 ++++++------- 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b5905d4ad..ab245ee3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1394,7 +1394,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "117725a109d387c937a1533ce01b450cbde6b88abceea8473c4d7a85853cda3c" dependencies = [ "lazy_static", - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] @@ -2046,6 +2046,12 @@ dependencies = [ "subtle", ] +[[package]] +name = "dioxus-debug-cell" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea539174bb236e0e7dc9c12b19b88eae3cb574dedbd0252a2d43ea7e6de13e2" + [[package]] name = "dirs" version = "5.0.1" @@ -2085,7 +2091,7 @@ dependencies = [ "libc", "option-ext", "redox_users 0.5.0", - "windows-sys 0.60.2", + "windows-sys 0.61.1", ] [[package]] @@ -4480,7 +4486,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" dependencies = [ "cfg-if", - "windows-targets 0.48.5", + "windows-targets 0.52.6", ] [[package]] @@ -6007,7 +6013,7 @@ dependencies = [ "aes-gcm", "aes-kw", "argon2", - "base64 0.21.7", + "base64 0.22.1", "bitfield", "block-padding", "blowfish", @@ -7392,7 +7398,7 @@ dependencies = [ "security-framework 3.5.1", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.60.2", + "windows-sys 0.61.1", ] [[package]] @@ -9078,6 +9084,7 @@ dependencies = [ "base64 0.22.1", "cef", "cef-dll-sys", + "dioxus-debug-cell", "dirs 6.0.0", "gtk", "html5ever", @@ -10552,7 +10559,7 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" dependencies = [ - "windows-sys 0.48.0", + "windows-sys 0.59.0", ] [[package]] diff --git a/crates/tauri-runtime-cef/Cargo.toml b/crates/tauri-runtime-cef/Cargo.toml index 646b882da..eb4046ec2 100644 --- a/crates/tauri-runtime-cef/Cargo.toml +++ b/crates/tauri-runtime-cef/Cargo.toml @@ -10,6 +10,7 @@ edition.workspace = true rust-version.workspace = true [dependencies] +dioxus-debug-cell = "0.1" tauri-runtime = { version = "2.9.2", path = "../tauri-runtime" } tauri-utils = { version = "2.8.0", path = "../tauri-utils", features = [ "html-manipulation", diff --git a/crates/tauri-runtime-cef/src/cef_impl.rs b/crates/tauri-runtime-cef/src/cef_impl.rs index 028d023db..90ef71585 100644 --- a/crates/tauri-runtime-cef/src/cef_impl.rs +++ b/crates/tauri-runtime-cef/src/cef_impl.rs @@ -4,9 +4,9 @@ use base64::Engine; use cef::{rc::*, *}; +use dioxus_debug_cell::RefCell; use sha2::{Digest, Sha256}; use std::{ - cell::RefCell, collections::HashMap, sync::{ atomic::{AtomicBool, AtomicU32, Ordering}, @@ -831,7 +831,7 @@ wrap_browser_view_delegate! { impl BrowserViewDelegate { fn on_browser_created(&self, _browser_view: Option<&mut BrowserView>, browser: Option<&mut Browser>) { if let Some(browser) = browser { - self.browser_id.replace(browser.identifier()); + let _ = std::mem::replace(&mut *self.browser_id.borrow_mut(), browser.identifier()); } } @@ -2586,7 +2586,7 @@ wrap_task! { impl Task { fn execute(&self) { - handle_message(&self.context, self.message.replace(Message::Noop)); + handle_message(&self.context, std::mem::replace(&mut self.message.borrow_mut(), Message::Noop)); } } } diff --git a/crates/tauri-runtime-cef/src/cef_impl/request_handler.rs b/crates/tauri-runtime-cef/src/cef_impl/request_handler.rs index ad2a3bcff..b08c0870a 100644 --- a/crates/tauri-runtime-cef/src/cef_impl/request_handler.rs +++ b/crates/tauri-runtime-cef/src/cef_impl/request_handler.rs @@ -4,12 +4,12 @@ use std::{ borrow::Cow, - cell::RefCell, io::{Cursor, Read}, sync::Arc, }; use cef::{rc::*, *}; +use dioxus_debug_cell::RefCell; use html5ever::{interface::QualName, namespace_url, ns, LocalName}; use http::{ header::{CONTENT_SECURITY_POLICY, CONTENT_TYPE}, diff --git a/crates/tauri-runtime-cef/src/lib.rs b/crates/tauri-runtime-cef/src/lib.rs index 820f605f2..117829d85 100644 --- a/crates/tauri-runtime-cef/src/lib.rs +++ b/crates/tauri-runtime-cef/src/lib.rs @@ -27,8 +27,8 @@ use url::Url; #[cfg(windows)] use windows::Win32::Foundation::HWND; +use dioxus_debug_cell::RefCell; use std::{ - cell::RefCell, collections::HashMap, fmt, fs::create_dir_all, @@ -2210,11 +2210,9 @@ impl Runtime for CefRuntime { let callback = Arc::new(RefCell::new(callback)); let callback_ = callback.clone(); let event_tx_ = self.event_tx.clone(); - let _ = self - .context - .cef_context - .callback - .replace(Box::new(move |event| { + let _ = std::mem::replace( + &mut *self.context.cef_context.callback.borrow_mut(), + Box::new(move |event| { if let RunEvent::Exit = event { // notify the event loop to exit let _ = event_tx_.send(RunEvent::Exit); @@ -2226,7 +2224,8 @@ impl Runtime for CefRuntime { let _ = event_tx_.send(event); } } - })); + }), + ); 'main_loop: loop { while let Ok(event) = self.event_rx.try_recv() {