Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,20 @@ fn app() -> Element {

fn popup(send: Rc<dyn Fn(String)>) -> 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());
Expand Down
8 changes: 1 addition & 7 deletions examples/window_focus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/virtual_dom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Runtime>` references
self.runtime.pending_effects.borrow_mut().clear();
self.runtime.tasks.borrow_mut().clear();
self.runtime.mounts.borrow_mut().clear();
}
}

Expand Down
Loading