Fixed the multiple window closing issue, where the two multiwindow examples weren't working. (#3499)
* fixed window when multiple windows not closing * fixed window when multiple windows not closing * fixed accidental includes * polished * fix last window closing hiding app and rc hardcount * find the suspect strong count holders and fix them * Use the proper type alias * fmt --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
36522cf3ea
commit
25a64d97c0
6 files changed
+45
-19
No files matched your search
@@ -1,11 +1,11 @@
|
||||
use crate::{query::Query, DesktopContext, WeakDesktopContext};
|
||||
use dioxus_core::prelude::queue_effect;
|
||||
use dioxus_document::{
|
||||
create_element_in_head, Document, Eval, EvalError, Evaluator, LinkProps, MetaProps,
|
||||
ScriptProps, StyleProps,
|
||||
};
|
||||
use generational_box::{AnyStorage, GenerationalBox, UnsyncStorage};
|
||||
|
||||
use crate::{query::Query, DesktopContext};
|
||||
use generational_box::{AnyStorage, GenerationalBox, UnsyncStorage};
|
||||
|
||||
/// Code for the Dioxus channel used to communicate between the dioxus and javascript code
|
||||
pub const NATIVE_EVAL_JS: &str = include_str!("./js/native_eval.js");
|
||||
@@ -13,22 +13,30 @@ pub const NATIVE_EVAL_JS: &str = include_str!("./js/native_eval.js");
|
||||
/// Represents the desktop-target's provider of evaluators.
|
||||
#[derive(Clone)]
|
||||
pub struct DesktopDocument {
|
||||
pub(crate) desktop_ctx: DesktopContext,
|
||||
pub(crate) desktop_ctx: WeakDesktopContext,
|
||||
}
|
||||
|
||||
impl DesktopDocument {
|
||||
pub fn new(desktop_ctx: DesktopContext) -> Self {
|
||||
let desktop_ctx = std::rc::Rc::downgrade(&desktop_ctx);
|
||||
Self { desktop_ctx }
|
||||
}
|
||||
}
|
||||
|
||||
impl Document for DesktopDocument {
|
||||
fn eval(&self, js: String) -> Eval {
|
||||
Eval::new(DesktopEvaluator::create(self.desktop_ctx.clone(), js))
|
||||
Eval::new(DesktopEvaluator::create(
|
||||
self.desktop_ctx
|
||||
.upgrade()
|
||||
.expect("Window to exist when document is alive"),
|
||||
js,
|
||||
))
|
||||
}
|
||||
|
||||
fn set_title(&self, title: String) {
|
||||
self.desktop_ctx.window.set_title(&title);
|
||||
if let Some(ctx) = self.desktop_ctx.upgrade() {
|
||||
ctx.set_title(&title);
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new meta tag in the head
|
||||
|
||||
Reference in new issue
Block a user