From e9c1938cdce5fc6de57eee167eaf6f1519fc6c8d Mon Sep 17 00:00:00 2001 From: Rafael Mendes <57309097+RafaelMendes1407@users.noreply.github.com> Date: Thu, 5 Nov 2026 13:30:48 -0300 Subject: [PATCH] Wait for relief builds and keep platform-specific tests warning-free --- crates/automation/src/rpc.rs | 4 ++-- crates/ui-egui/src/view3d.rs | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/crates/automation/src/rpc.rs b/crates/automation/src/rpc.rs index 82d99fd..3befa2a 100644 --- a/crates/automation/src/rpc.rs +++ b/crates/automation/src/rpc.rs @@ -330,7 +330,7 @@ mod tests { #[test] fn material_export_cannot_escape_the_write_root() { - let (inside, outside, h) = workspace_session("mat-escape", true); + let (_inside, outside, h) = workspace_session("mat-escape", true); let abs = outside.join("abs.mcmat").display().to_string(); for p in ["../outside/m.mcmat", "a/../../outside/m.mcmat", "/tmp/m.mcmat", "a\\b.mcmat", "C:/m.mcmat", "./m.mcmat", abs.as_str()] { let e = call(&h, "material.export", json!({"path": p, "size": 16})); @@ -338,7 +338,7 @@ mod tests { } #[cfg(unix)] { - std::os::unix::fs::symlink(&outside, inside.join("link")).unwrap(); + std::os::unix::fs::symlink(&outside, _inside.join("link")).unwrap(); assert!(call(&h, "material.export", json!({"path": "link/m.mcmat", "size": 16})).is_err()); } assert_eq!(std::fs::read_dir(&outside).unwrap().count(), 0, "nothing written outside the root"); diff --git a/crates/ui-egui/src/view3d.rs b/crates/ui-egui/src/view3d.rs index d437905..7d02032 100644 --- a/crates/ui-egui/src/view3d.rs +++ b/crates/ui-egui/src/view3d.rs @@ -59,9 +59,9 @@ pub struct View3dState { } impl View3dState { - /// A full-quality frame is rendering in the background. + /// A frame or its displaced geometry is still being built in the background. pub fn busy(&self) -> bool { - self.job.is_some() + self.job.is_some() || self.relief_job.is_some() } } @@ -406,11 +406,11 @@ fn relief_key(app: &MaterialCraftApp, scene_key: &str, maps: &Maps) -> Option Option { let (scene_key, base) = base_scene(app); let maps = Maps::from_usages(app.session.material_maps()); - let wanted = relief_key(app, &scene_key, &maps)?; + let wanted = relief_key(app, &scene_key, &maps); if let Some(job) = app.view3d.relief_job.take() { match job.rx.try_recv() { - Ok(Some(scene)) if job.key == wanted => app.view3d.displaced = Some((job.key, scene)), + Ok(Some(scene)) if Some(job.key) == wanted => app.view3d.displaced = Some((job.key, scene)), Ok(_) | Err(TryRecvError::Disconnected) => {} // Finish the active build before starting a newer one. Dropping its receiver // cannot cancel subdivision, so rapid edits must not accumulate workers. @@ -418,6 +418,8 @@ fn update_relief(app: &mut MaterialCraftApp, ctx: &egui::Context) -> Option } } + let wanted = wanted?; + if app.view3d.displaced.as_ref().is_some_and(|(key, _)| *key == wanted) { return Some(wanted); } @@ -567,6 +569,7 @@ mod tests { app.session.view3d.height_scale = index as f32 * 0.001; assert_eq!(update_relief(&mut app, &ctx), None); assert_eq!(app.view3d.relief_job.as_ref().unwrap().key, old_key, "a second subdivision worker started"); + assert!(app.view3d.busy(), "geometry work must count as a busy view"); } let wanted = relief_key(&app, &scene_key, &maps).unwrap(); assert_ne!(old_key, wanted); @@ -574,6 +577,7 @@ mod tests { tx.send(Some(Arc::new(Scene::builtin("sphere")))).unwrap(); assert_eq!(update_relief(&mut app, &ctx), Some(wanted)); assert!(app.view3d.relief_job.is_none()); + assert!(!app.view3d.busy()); assert!(Arc::ptr_eq(&app.view3d.displaced.as_ref().unwrap().1, &base), "outdated geometry replaced the current scene"); }