fix(layers): protect locked entities

Keep locked-layer objects selectable for inspection while suppressing grips, property edits, command mutations, and stale editor writes.
This commit is contained in:
Hakan Seven committed 2026-08-12 12:46:41 +03:00
1 parent ca331fff48
commit 0be9c41773
25 files changed
+524 -118

No files matched your search

+39 -5
View File
@@ -30,6 +30,7 @@ impl OpenCADStudio {
.selected_entities()
.iter()
.map(|(h, _)| *h)
.filter(|handle| !self.tabs[i].scene.is_layer_locked(*handle))
.collect();
let mut found = false;
for sh in &selected_handles {
@@ -389,8 +390,20 @@ impl OpenCADStudio {
"SET" => {
let app = parts.get(1).copied().unwrap_or("OpenCADStudio");
let val = parts.get(2).copied().unwrap_or("");
let editable: Vec<_> = selected_handles
.iter()
.copied()
.filter(|handle| !self.tabs[i].scene.is_layer_locked(*handle))
.collect();
if editable.is_empty() {
self.command_line.push_error(
crate::t!("XDATA: selected entities are on locked layers.")
.as_ref(),
);
return Some(Task::none());
}
self.push_undo_snapshot(i, "XDATA SET");
for sh in &selected_handles {
for sh in &editable {
if let Some(entity) =
self.tabs[i].scene.document.get_entity_mut(*sh)
{
@@ -402,13 +415,25 @@ impl OpenCADStudio {
self.tabs[i].dirty = true;
self.command_line.push_output(crate::tf!(
"XDATA: set [{app}] = \"{val}\" on {} entity/entities.",
selected_handles.len()
editable.len()
).as_ref());
}
"CLEAR" => {
let app_filter = parts.get(1).copied();
let editable: Vec<_> = selected_handles
.iter()
.copied()
.filter(|handle| !self.tabs[i].scene.is_layer_locked(*handle))
.collect();
if editable.is_empty() {
self.command_line.push_error(
crate::t!("XDATA: selected entities are on locked layers.")
.as_ref(),
);
return Some(Task::none());
}
self.push_undo_snapshot(i, "XDATA CLEAR");
for sh in &selected_handles {
for sh in &editable {
if let Some(entity) =
self.tabs[i].scene.document.get_entity_mut(*sh)
{
@@ -600,6 +625,7 @@ impl OpenCADStudio {
.selected_entities()
.iter()
.map(|(h, _)| *h)
.filter(|handle| !self.tabs[i].scene.is_layer_locked(*handle))
.collect();
if handles.is_empty() {
self.command_line
@@ -706,6 +732,7 @@ impl OpenCADStudio {
.selected_entities()
.iter()
.map(|(h, _)| *h)
.filter(|handle| !self.tabs[i].scene.is_layer_locked(*handle))
.collect();
if handles.is_empty() {
self.command_line
@@ -765,8 +792,13 @@ impl OpenCADStudio {
self.command_line.push_info(crate::t!("Usage: HYPERLINK <url> (select objects first)").as_ref());
return Some(Task::none());
}
let handles: Vec<acadrust::Handle> =
self.tabs[i].scene.selected_entities().iter().map(|(h, _)| *h).collect();
let handles: Vec<acadrust::Handle> = self.tabs[i]
.scene
.selected_entities()
.iter()
.map(|(h, _)| *h)
.filter(|handle| !self.tabs[i].scene.is_layer_locked(*handle))
.collect();
if handles.is_empty() {
self.command_line.push_error(crate::t!("HYPERLINK: select objects first.").as_ref());
return Some(Task::none());
@@ -816,6 +848,7 @@ impl OpenCADStudio {
.selected_entities()
.iter()
.map(|(h, _)| *h)
.filter(|handle| !self.tabs[i].scene.is_layer_locked(*handle))
.collect();
if handles.is_empty() {
self.command_line
@@ -938,6 +971,7 @@ impl OpenCADStudio {
.selected_entities()
.iter()
.map(|(handle, _)| *handle)
.filter(|handle| !self.tabs[i].scene.is_layer_locked(*handle))
.collect();
if handles.is_empty() {
self.command_line