Fixed draw_children

This commit is contained in:
2026-01-31 15:46:59 +01:00
parent 5017895a30
commit 89161ab39b
+17 -10
View File
@@ -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| {
let mut c = shared_ctx.lock().unwrap();
for (child, view_wrapper) in children { for (child, view_wrapper) in children {
let view = child.get_view(); 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);
} }
} }
tx.send(c.clone()).expect("Failed transmitting DrawContext"); let _ = tx_done.send(());
}); });
} }
}
}); });
*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> {