feat: bless up, no more segfaults

This commit is contained in:
Jonathan Kelley committed 2021-07-26 12:14:48 -04:00
1 parent 7dfe89c958
commit 4a0068f099
14 files changed
+548 -274

No files matched your search

+13 -13
View File
@@ -2,32 +2,32 @@
use dioxus_core::{DomEdit, RealDom};
pub struct WebviewRegistry {}
// pub struct WebviewRegistry {}
impl WebviewRegistry {
pub fn new() -> Self {
Self {}
}
}
// impl WebviewRegistry {
// pub fn new() -> Self {
// Self {}
// }
// }
pub struct WebviewDom<'bump> {
pub edits: Vec<DomEdit<'bump>>,
pub node_counter: u64,
pub registry: WebviewRegistry,
// pub registry: WebviewRegistry,
}
impl WebviewDom<'_> {
pub fn new(registry: WebviewRegistry) -> Self {
pub fn new() -> Self {
Self {
edits: Vec::new(),
node_counter: 0,
registry,
// registry,
}
}
// Finish using the dom (for its edit list) and give back the node and event registry
pub fn consume(self) -> WebviewRegistry {
self.registry
}
// // Finish using the dom (for its edit list) and give back the node and event registry
// pub fn consume(self) -> WebviewRegistry {
// self.registry
// }
}
impl<'bump> RealDom<'bump> for WebviewDom<'bump> {
fn raw_node_as_any(&self) -> &mut dyn std::any::Any {
+4
View File
@@ -29,6 +29,10 @@
this.stack.push(node);
}
PopRoot(edit) {
this.stack.pop();
}
AppendChildren(edit) {
let root = this.stack[this.stack.length - (edit.many + 1)];
for (let i = 0; i < edit.many; i++) {
+9 -9
View File
@@ -70,7 +70,7 @@ impl<T: Properties + 'static> WebviewRenderer<T> {
// todo: combine these or something
let vdom = Arc::new(RwLock::new(vir));
let registry = Arc::new(RwLock::new(Some(WebviewRegistry::new())));
// let registry = Arc::new(RwLock::new(Some(WebviewRegistry::new())));
let webview = WebViewBuilder::new(window)?
// .with_visible(false)
@@ -83,10 +83,10 @@ impl<T: Properties + 'static> WebviewRenderer<T> {
serde_json::to_value(edits).unwrap()
} else {
let mut lock = vdom.write().unwrap();
let mut reg_lock = registry.write().unwrap();
// let mut reg_lock = registry.write().unwrap();
// Create the thin wrapper around the registry to collect the edits into
let mut real = dom::WebviewDom::new(reg_lock.take().unwrap());
let mut real = dom::WebviewDom::new();
// Serialize the edit stream
let edits = {
@@ -96,7 +96,7 @@ impl<T: Properties + 'static> WebviewRenderer<T> {
};
// Give back the registry into its slot
*reg_lock = Some(real.consume());
// *reg_lock = Some(real.consume());
edits
};
@@ -106,11 +106,11 @@ impl<T: Properties + 'static> WebviewRenderer<T> {
"user_event" => {
log::debug!("User event received");
let registry = registry.clone();
// let registry = registry.clone();
let vdom = vdom.clone();
let response = async_std::task::block_on(async move {
let mut lock = vdom.write().unwrap();
let mut reg_lock = registry.write().unwrap();
// let mut reg_lock = registry.write().unwrap();
// a deserialized event
let data = req.params.unwrap();
@@ -120,7 +120,7 @@ impl<T: Properties + 'static> WebviewRenderer<T> {
lock.queue_event(event);
// Create the thin wrapper around the registry to collect the edits into
let mut real = dom::WebviewDom::new(reg_lock.take().unwrap());
let mut real = dom::WebviewDom::new();
// Serialize the edit stream
//
@@ -131,7 +131,7 @@ impl<T: Properties + 'static> WebviewRenderer<T> {
let edits = serde_json::to_value(edits).unwrap();
// Give back the registry into its slot
*reg_lock = Some(real.consume());
// *reg_lock = Some(real.consume());
// Return the edits into the webview runtime
Some(RpcResponse::new_result(req.id.take(), Some(edits)))
@@ -206,7 +206,7 @@ impl<T: Properties + 'static> WebviewRenderer<T> {
use serde::{Deserialize, Serialize};
use serde_json::Value;
use crate::dom::WebviewRegistry;
// use crate::dom::WebviewRegistry;
#[derive(Debug, Serialize, Deserialize)]
struct MessageParameters {