fix(properties): renamed, added and removed layers reach the layer list

The Properties palette reads the layer names when it is built, and a
layer rename only refreshed the layer panel and the ribbon, so the
palette's layer list kept the old name beside the new one. The layer
panel refresh now rebuilds the palette whenever the set of layer names
changed: rename, new, delete and purge all pass through it. A layer
toggle that leaves the names alone does not rebuild it, as the rebuild is
costly for a large selection.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-08 14:41:52 +03:00
1 parent 1e4c10bc6b
commit e82e97b0d9
1 file changed
+15
+15
View File
@@ -62,10 +62,25 @@ impl OpenCADStudio {
let i = self.active_tab;
let doc_layers = self.tabs[i].scene.document.layers.clone();
let vp_info = self.tabs[i].scene.viewport_list();
let names_before: Vec<String> =
self.tabs[i].layers.layers.iter().map(|l| l.name.clone()).collect();
self.tabs[i]
.layers
.sync_with_viewports(&doc_layers, vp_info);
self.sync_ribbon_layers();
// The Properties palette lists layer names it read when it was built;
// a layer added, removed or renamed must reach that list too (#1664).
// Only then: the rebuild is costly for a large selection.
let names_changed = self.tabs[i].layers.layers.len() != names_before.len()
|| self.tabs[i]
.layers
.layers
.iter()
.zip(&names_before)
.any(|(layer, before)| layer.name != *before);
if names_changed {
self.refresh_properties();
}
}
/// Pick up layers an entity edit registered on the fly (`ensure_layer`).