From b2b84283aea85ce3942a0e911cefc41cf8cbb3ad Mon Sep 17 00:00:00 2001 From: Hakan Seven Date: Tue, 25 Aug 2026 23:21:24 +0300 Subject: [PATCH] fix(io): trust decoded current layer Remove the application-side CLAYER fallback now that cadcodec resolves the header handle during document construction. Refs #743 --- Cargo.lock | 2 +- Cargo.toml | 4 ++-- src/app/update/file.rs | 34 ++++++---------------------------- 3 files changed, 9 insertions(+), 31 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cbd9f3b66..babff4253 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -72,7 +72,7 @@ checksum = "366ffbaa4442f4684d91e2cd7c5ea7c4ed8add41959a31447066e279e432b618" [[package]] name = "acadrust" version = "0.4.1" -source = "git+https://git@github.com/HakanSeven12/cadcodec.git?rev=2aa1181#2aa1181776b7c1848efe58e3d41ed35138ed7455" +source = "git+https://git@github.com/HakanSeven12/cadcodec.git?rev=9f3cf8e#9f3cf8e26d5a02fb4ad8ea145ca8e04dd6d6f2bc" dependencies = [ "ahash 0.8.12", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 7a0b74acc..02b96ca95 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ glam = { version = "0.33", features = ["bytemuck"] } rfd = "0.17" clap = { version = "4", features = ["derive"] } env_logger = "0.11" -acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "2aa1181", features = ["serde"] } +acadrust = { git = "https://github.com/HakanSeven12/cadcodec.git", rev = "9f3cf8e", features = ["serde"] } cadkernel = { git = "https://github.com/HakanSeven12/cadkernel.git", rev = "b2b1d4b", features = ["acis", "offset"] } dwg-thumbnailer = { path = "crates/dwg-thumbnailer" } flate2 = "1" @@ -61,7 +61,7 @@ iced_core = { git = "https://github.com/iced-rs/iced.git", rev = "23604ff22ab0aa iced_widget = { git = "https://github.com/iced-rs/iced.git", rev = "23604ff22ab0aad9e00b9327cb7b8546ed84db39" } [patch."https://github.com/HakanSeven12/cadcodec.git"] -acadrust = { git = "https://git@github.com/HakanSeven12/cadcodec.git", rev = "2aa1181" } +acadrust = { git = "https://git@github.com/HakanSeven12/cadcodec.git", rev = "9f3cf8e" } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] ocs_plugin_api = { path = "crates/ocs_plugin_api", features = ["host"] } diff --git a/src/app/update/file.rs b/src/app/update/file.rs index 10a95940e..4cf472e7c 100644 --- a/src/app/update/file.rs +++ b/src/app/update/file.rs @@ -1187,34 +1187,12 @@ pub(super) fn on_open_file(&mut self) -> Task { self.tabs[i].scene.material_base_dir = path.parent().map(std::path::Path::to_path_buf); self.tabs[i].scene.document = doc; - // DWG stores CLAYER as a layer handle. Resolve that handle back to - // the layer name after opening so the per-tab creation state and - // header name stay in sync. DXF already provides current_layer_name, - // so keep it as a fallback. - let current_layer = { - let doc = &self.tabs[i].scene.document; - - doc.layers - .iter() - .find(|layer| layer.handle == doc.header.current_layer_handle) - .map(|layer| (layer.name.clone(), layer.handle)) - .or_else(|| { - doc.layers - .get(&doc.header.current_layer_name) - .map(|layer| (layer.name.clone(), layer.handle)) - }) - .or_else(|| { - doc.layers - .get("0") - .map(|layer| (layer.name.clone(), layer.handle)) - }) - }; - - if let Some((name, handle)) = current_layer { - self.tabs[i].scene.document.header.current_layer_name = name.clone(); - self.tabs[i].scene.document.header.current_layer_handle = handle; - self.tabs[i].active_layer = name; - } + self.tabs[i].active_layer = self.tabs[i] + .scene + .document + .header + .current_layer_name + .clone(); // A file saved without the built-in Standard styles (foreign // or damaged) gets them re-seeded so nothing dangles (#366). crate::app::style_ops::ensure_standard_styles(