Fixed draw_children
This commit is contained in:
+26
-19
@@ -195,30 +195,37 @@ impl Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_children(self: &Arc<Self>, ctx: &mut DrawContext) {
|
pub fn draw_children(self: &Arc<Self>, ctx: &mut DrawContext) {
|
||||||
let c = ctx.clone();
|
let scope_count = self.scopes.access_ref().len();
|
||||||
|
let shared_ctx = Arc::new(Mutex::new(ctx.clone()));
|
||||||
|
let (tx_done, rx_done) = std::sync::mpsc::channel::<()>();
|
||||||
|
|
||||||
let (tx, rx) = std::sync::mpsc::channel::<DrawContext>();
|
self.scopes.access({
|
||||||
|
let shared_ctx = shared_ctx.clone();
|
||||||
self.scopes.access(move |scopes| {
|
move |scopes| {
|
||||||
for scope in scopes {
|
for scope in scopes {
|
||||||
let mut c = c.clone();
|
let shared_ctx = shared_ctx.clone();
|
||||||
let tx = tx.clone();
|
let tx_done = tx_done.clone();
|
||||||
scope.access_children(move |children| {
|
scope.access_children(move |children| {
|
||||||
for (child, view_wrapper) in children {
|
let mut c = shared_ctx.lock().unwrap();
|
||||||
let view = child.get_view();
|
for (child, view_wrapper) in children {
|
||||||
|
let view = child.get_view();
|
||||||
if let Some(view_wrapper) = view_wrapper {
|
if let Some(view_wrapper) = view_wrapper {
|
||||||
view_wrapper(&mut c, view)
|
view_wrapper(&mut c, view)
|
||||||
} else {
|
} else {
|
||||||
c.draw_view(c.area.clone(), view);
|
let area = c.area.clone();
|
||||||
|
c.draw_view(area, view);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
let _ = tx_done.send(());
|
||||||
tx.send(c.clone()).expect("Failed transmitting DrawContext");
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
*ctx = rx.recv().expect("Failed receiving DrawContext");
|
for _ in 0..scope_count {
|
||||||
|
rx_done.recv().expect("Failed receiving done signal");
|
||||||
|
}
|
||||||
|
*ctx = shared_ctx.lock().unwrap().clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_executor(self: &Arc<Self>) -> Arc<dyn CommandExecutor> {
|
pub fn get_executor(self: &Arc<Self>) -> Arc<dyn CommandExecutor> {
|
||||||
|
|||||||
Reference in New Issue
Block a user