forked from 1b-agent/opencadstudio-upstream
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:
1 parent
ca331fff48
commit
0be9c41773
25 files changed
+524
-118
No files matched your search
@@ -125,6 +125,9 @@ impl super::OpenCADStudio {
|
||||
/// the plain box (the rich editor needs no field focus).
|
||||
pub(super) fn begin_text_edit(&mut self, handle: Handle) -> iced::Task<super::Message> {
|
||||
let i = self.active_tab;
|
||||
if self.tabs[i].scene.is_layer_locked(handle) {
|
||||
return iced::Task::none();
|
||||
}
|
||||
// Resolve a Leader chain to the annotated entity.
|
||||
let mut target = handle;
|
||||
for _ in 0..8 {
|
||||
@@ -139,6 +142,9 @@ impl super::OpenCADStudio {
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
if self.tabs[i].scene.is_layer_locked(target) {
|
||||
return iced::Task::none();
|
||||
}
|
||||
// Snapshot what we need before borrowing `self` mutably to open.
|
||||
let Some(entity) = self.tabs[i].scene.document.get_entity(target) else {
|
||||
return iced::Task::none();
|
||||
@@ -178,6 +184,9 @@ impl super::OpenCADStudio {
|
||||
height: f64,
|
||||
field: TextEntityField,
|
||||
) {
|
||||
if handle.is_some_and(|h| self.tabs[self.active_tab].scene.is_layer_locked(h)) {
|
||||
return;
|
||||
}
|
||||
let mut state = TextInlineState {
|
||||
pos,
|
||||
value: initial.to_string(),
|
||||
@@ -202,6 +211,10 @@ impl super::OpenCADStudio {
|
||||
return false;
|
||||
}
|
||||
if let Some(h) = ed.editing {
|
||||
if self.tabs[i].scene.is_layer_locked(h) {
|
||||
self.refresh_properties();
|
||||
return false;
|
||||
}
|
||||
self.push_undo_snapshot(i, "TEXT");
|
||||
if let Some(entity) = self.tabs[i].scene.document.get_entity_mut(h) {
|
||||
write_text_field(entity, ed.field, ed.value.clone());
|
||||
|
||||
Reference in new issue
Block a user