diff --git a/examples/popup.rs b/examples/popup.rs index 56d422acaa..675d999005 100644 --- a/examples/popup.rs +++ b/examples/popup.rs @@ -43,10 +43,20 @@ fn app() -> Element { fn popup(send: Rc) -> Element { let mut user_input = use_signal(String::new); + let window = dioxus::desktop::use_window(); + + let close_window = move |_| { + println!("Attempting to close Window B"); + window.close(); + }; rsx! { div { h1 { "Compose a new email" } + button { + onclick: close_window, + "Close Window B (button)" + } button { onclick: move |_| { send(user_input.cloned()); diff --git a/examples/window_focus.rs b/examples/window_focus.rs index 20b81f8758..9290c766dc 100644 --- a/examples/window_focus.rs +++ b/examples/window_focus.rs @@ -8,16 +8,10 @@ use dioxus::desktop::tao::event::Event as WryEvent; use dioxus::desktop::tao::event::WindowEvent; use dioxus::desktop::use_wry_event_handler; -use dioxus::desktop::{Config, DefaultWindowCloseBehaviour}; use dioxus::prelude::*; fn main() { - dioxus::LaunchBuilder::desktop() - .with_cfg( - Config::new() - .with_default_window_close_behaviour(DefaultWindowCloseBehaviour::WindowsCloses), - ) - .launch(app) + dioxus::launch(app); } fn app() -> Element { diff --git a/packages/core/src/virtual_dom.rs b/packages/core/src/virtual_dom.rs index 1beaafd6a8..a7774e7db2 100644 --- a/packages/core/src/virtual_dom.rs +++ b/packages/core/src/virtual_dom.rs @@ -773,6 +773,11 @@ impl Drop for VirtualDom { for scope in scopes.into_iter().rev() { drop(scope); } + + // Drop the mounts, tasks, and effects, releasing any `Rc` references + self.runtime.pending_effects.borrow_mut().clear(); + self.runtime.tasks.borrow_mut().clear(); + self.runtime.mounts.borrow_mut().clear(); } }