Scripts: path points of other Global Edit members go stale when Global Edit changes them

While Global Edit is on, an object model edit of one member (or a move
of a group that holds it) is given to the other members, but the check
that marks read PathPoint handles stale only looked at the edited
object's own subtree. A script that read a point of another member kept
a valid handle after the edit, even when an undo then put the member
back. The check now also looks at each Global Edit member, or the
outermost Objects on Path group that holds it, and skips subtrees the
command left as they were. The stale-point check came in with #9288.

Docs: docs/mcp.md, docs/target-app-parity.md.
This commit is contained in:
dotCooCoo committed 2026-12-02 22:34:57 -08:00
1 parent 4002b2b66c
commit ced550ebef
4 files changed
+88 -9

No files matched your search

+19 -7
View File
@@ -1375,7 +1375,8 @@ fn see_points(h: &super::Host, key: (u64, u64), own: impl FnOnce() -> bool) {
/// [`see_points`] for each path whose points the run has read, after each command, so that a
/// change that a later command reverses still makes the points stale. Paths under the object that
/// the object model is changing ([`super::State`]), or that object itself, take the change as the
/// object model's own, and their points stay valid. A document that is the one the run last looked
/// object model's own, and their points stay valid; the other Global Edit members, which take the
/// object model's edit too, are looked at as well. A document that is the one the run last looked
/// at is skipped, as are its paths.
pub(super) fn see_all_points(h: &super::Host) {
let keys: Vec<(u64, u64)> = {
@@ -1384,18 +1385,27 @@ pub(super) fn see_all_points(h: &super::Host) {
let seen = h.dom.point_nodes.borrow();
let mut keys = Vec::new();
docs.retain(|uid, before| {
let after = s.documents().iter().find(|d| d.uid == *uid).map(|st| &st.doc);
let state = s.documents().iter().find(|d| d.uid == *uid);
let after = state.map(|st| &st.doc);
if after.is_some_and(|after| Arc::ptr_eq(before, after)) {
return true;
}
// Editing a path in an Objects on Path group can move the other paths in the group, so
// the outermost such group is looked at in place of the path.
// the outermost such group is looked at in place of the path. While Global Edit is on,
// an edit of the selected member (also one made by moving a group that holds it) is
// given to the other members, so each of them, or the outermost Objects on Path group
// holding it, is looked at too. Subtrees the command left as they were are skipped.
let mut todo: Vec<_> = match h.dom.editing.get().filter(|item| item.doc.uid == *uid) {
Some(item) => {
let group = before
.ancestry(item.id)
.and_then(|a| a.into_iter().find(|g| before.node(*g).is_some_and(vectorcraft_doc::objects_on_path::is_objects_on_path)));
node_arc(before, group.unwrap_or(item.id)).into_iter().collect()
let root = |id: NodeId| {
before
.ancestry(id)
.and_then(|a| a.into_iter().find(|g| before.node(*g).is_some_and(vectorcraft_doc::objects_on_path::is_objects_on_path)))
.unwrap_or(id)
};
let members = state.and_then(|st| st.global_edit.as_ref()).map(|ge| ge.members.iter().map(|(id, _)| *id)).into_iter().flatten();
let mut roots = std::collections::HashSet::new();
std::iter::once(item.id).chain(members).map(root).filter(|id| roots.insert(*id)).filter_map(|id| node_arc(before, id)).collect()
}
None => before.layers.iter().collect(),
};
@@ -1417,6 +1427,8 @@ pub(super) fn see_all_points(h: &super::Host) {
false
}
});
keys.sort_unstable();
keys.dedup();
keys
};
let editing = h.dom.editing.get();