forked from 1b-agent/opencadstudio-upstream
fix(blocks): a copied dynamic reference changes state on its own (#1818)
COPY cloned the reference's AcDbRepData without its handle, owner or representation index, and both references kept sharing one evaluated *U block, so a state picked on either changed both. The clone now names itself and is indexed; a state change gives a reference whose *U other references share its own copy first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b947f99a87
commit
98cce048c7
3 files changed
+49
-26
No files matched your search
+5
-17
@@ -186,19 +186,11 @@ impl OpenCADStudio {
|
||||
return;
|
||||
}
|
||||
|
||||
// A reference to the definition itself gets an evaluated copy first,
|
||||
// so the state picked for it leaves the definition alone.
|
||||
let direct = {
|
||||
let doc = &self.tabs[i].scene.document;
|
||||
matches!(doc.get_entity(insert_handle), Some(EntityType::Insert(ins))
|
||||
if doc.block_records.get(&ins.block_name).is_some_and(|record| {
|
||||
crate::scene::block_visibility::parameter(doc, record.handle).is_some()
|
||||
}))
|
||||
};
|
||||
if direct {
|
||||
self.push_undo_snapshot(i, "Visibility State");
|
||||
self.tabs[i].scene.visibility_representation(insert_handle);
|
||||
}
|
||||
// A reference to the definition itself, or to a copy other
|
||||
// references share, gets its own evaluated copy first, so the state
|
||||
// picked for it leaves the definition and the others alone.
|
||||
self.push_undo_snapshot(i, "Visibility State");
|
||||
self.tabs[i].scene.visibility_representation(insert_handle);
|
||||
|
||||
// Resolve everything against an immutable borrow first.
|
||||
let mapping = {
|
||||
@@ -216,10 +208,6 @@ impl OpenCADStudio {
|
||||
return;
|
||||
};
|
||||
|
||||
if !direct {
|
||||
self.push_undo_snapshot(i, "Visibility State");
|
||||
}
|
||||
|
||||
// Apply invisibility flags to the anonymous block's members.
|
||||
{
|
||||
let doc = &mut self.tabs[i].scene.document;
|
||||
|
||||
Reference in new issue
Block a user