fix multiwindow due to mounts not dropping in virtualdom (#4351)
* fix handlers not dropping thanks to mounts * use `desktop` * Add tasks and effects * only destroy on virtualdom destroy * fix clippy
This commit is contained in:
1 parent
ff762cec84
commit
1db4b2a13d
3 files changed
+16
-7
No files matched your search
@@ -43,10 +43,20 @@ fn app() -> Element {
|
|||||||
|
|
||||||
fn popup(send: Rc<dyn Fn(String)>) -> Element {
|
fn popup(send: Rc<dyn Fn(String)>) -> Element {
|
||||||
let mut user_input = use_signal(String::new);
|
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! {
|
rsx! {
|
||||||
div {
|
div {
|
||||||
h1 { "Compose a new email" }
|
h1 { "Compose a new email" }
|
||||||
|
button {
|
||||||
|
onclick: close_window,
|
||||||
|
"Close Window B (button)"
|
||||||
|
}
|
||||||
button {
|
button {
|
||||||
onclick: move |_| {
|
onclick: move |_| {
|
||||||
send(user_input.cloned());
|
send(user_input.cloned());
|
||||||
|
|||||||
@@ -8,16 +8,10 @@
|
|||||||
use dioxus::desktop::tao::event::Event as WryEvent;
|
use dioxus::desktop::tao::event::Event as WryEvent;
|
||||||
use dioxus::desktop::tao::event::WindowEvent;
|
use dioxus::desktop::tao::event::WindowEvent;
|
||||||
use dioxus::desktop::use_wry_event_handler;
|
use dioxus::desktop::use_wry_event_handler;
|
||||||
use dioxus::desktop::{Config, DefaultWindowCloseBehaviour};
|
|
||||||
use dioxus::prelude::*;
|
use dioxus::prelude::*;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
dioxus::LaunchBuilder::desktop()
|
dioxus::launch(app);
|
||||||
.with_cfg(
|
|
||||||
Config::new()
|
|
||||||
.with_default_window_close_behaviour(DefaultWindowCloseBehaviour::WindowsCloses),
|
|
||||||
)
|
|
||||||
.launch(app)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn app() -> Element {
|
fn app() -> Element {
|
||||||
|
|||||||
@@ -773,6 +773,11 @@ impl Drop for VirtualDom {
|
|||||||
for scope in scopes.into_iter().rev() {
|
for scope in scopes.into_iter().rev() {
|
||||||
drop(scope);
|
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user