forked from 1b-agent/opencadstudio-upstream
fix(copy): a copy reacts only to what was copied with it
COPY and PASTE kept the source's reactors on each copy, so a copied dimension still pointed at the source's dimension association (and boundary or group members at the source hatch or group). Another application reports such a drawing as damaged and, after recovery, moves the dimensions. A copy's reactors now follow only targets copied with it; group copies give their members the new group's reactor; and a drawing opened with such stray dimension reactors has them dropped. Fixes #1645 Fixes #1649 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e2f558ae4f
commit
9adb6f59c8
6 files changed
+80
No files matched your search
@@ -823,6 +823,7 @@ impl Scene {
|
||||
|
||||
let _ = self.sync_displayed_annotation_context(leader_handle);
|
||||
}
|
||||
remap_copied_reactors(&mut self.document, &handle_map);
|
||||
// Complete group copies record their new Group objects and dictionary
|
||||
// entry as targeted object deltas inside copy_complete_groups.
|
||||
self.copy_complete_groups(&handle_map);
|
||||
@@ -1803,3 +1804,20 @@ impl Scene {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A copy reacts only to what was copied with it: each reactor of the source
|
||||
/// that maps to a copy follows it there, and the rest (the source's dimension
|
||||
/// association, group, associative hatch) are dropped. The association and
|
||||
/// group copies add their own reactors afterwards.
|
||||
pub(crate) fn remap_copied_reactors(
|
||||
document: &mut codec::CadDocument,
|
||||
handle_map: &rustc_hash::FxHashMap<Handle, Handle>,
|
||||
) {
|
||||
for © in handle_map.values() {
|
||||
let Some(entity) = document.get_entity_mut(copy) else {
|
||||
continue;
|
||||
};
|
||||
let reactors = &mut entity.common_mut().reactors;
|
||||
*reactors = reactors.iter().filter_map(|reactor| handle_map.get(reactor).copied()).collect();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user