Effects: Safe Mode checks graph design art that a blurred fill of its series group draws

effect.expandAppearance in Safe Mode left the art of a graph design in a
series out of the plug-in check unless an effect of the series group
itself would draw it. A raster effect on one of the group's fills or
strokes, such as a Gaussian Blur, also turns the whole group into an
image when it expands, art included, so a plug-in effect in that art was
expanded without drawing. Such a raster effect now keeps the art in the
check, and the command returns the Safe Mode error.
This commit is contained in:
dotCooCoo
2026-11-15 08:07:49 -08:00
parent 5ed83e0daa
commit 531ce2a10e
2 changed files with 21 additions and 3 deletions
+4 -3
View File
@@ -1302,15 +1302,16 @@ fn expand_appearance(s: &mut Session, p: &Value) -> Result<Value> {
if vectorcraft_plugins::safe_mode::active() {
// A dimension selected with the art it measures is left as it is, and so is the art of a graph design in a
// series, unless an effect of a group around it, the selected graph or series group or one inside it, draws it
// with that group.
// with that group: an effect of the group's own, or a raster effect of one of its fills or strokes (the group
// then becomes an image of all of it).
let mut d = super::dimension::without_kept(&s.doc()?.doc, &roots);
let draws_members = |g: &Node| g.appearance.effects.iter().any(|e| e.visible) || !rasterfx::raster_fx(g).is_empty();
let designs: Vec<NodeId> = super::appearance::design_art_in(&d, &roots)
.into_iter()
.filter(|art| {
!d.ancestry(*art).is_some_and(|up| {
let from = up.iter().position(|a| roots.contains(a)).unwrap_or(up.len());
up.get(from..up.len().saturating_sub(1))
.is_some_and(|around| around.iter().filter_map(|a| d.node(*a)).any(|g| g.appearance.effects.iter().any(|e| e.visible)))
up.get(from..up.len().saturating_sub(1)).is_some_and(|around| around.iter().filter_map(|a| d.node(*a)).any(draws_members))
})
})
.collect();
+17
View File
@@ -507,6 +507,23 @@ fn expand_appearance_in_safe_mode_checks_design_art_its_series_group_draws() {
let err = s.execute("effect.expandAppearance", &json!({})).unwrap_err().to_string();
safe_mode::set_active(None);
assert!(err.contains("a plug-in effect in the selection can't be expanded in Safe Mode"), "{err}");
// With a Gaussian Blur on a fill of the art's series group instead, expanding the group makes an image of it, art included.
let blurred_fill = {
let t = s.execute("shape.rectangle", &json!({"x": 700, "y": 40, "width": 10, "height": 10})).unwrap()["id"].as_u64().unwrap();
s.execute("effect.apply", &json!({"effect": "blur.gaussian", "ids": [t], "item": 0, "params": {"radius": 2}})).unwrap();
s.doc().unwrap().doc.node(vectorcraft_engine::doc::NodeId(t)).unwrap().appearance.items[0].clone()
};
{
let d = std::sync::Arc::make_mut(&mut s.doc_mut().unwrap().doc);
let g = d.node_mut(art_series).unwrap();
g.appearance.effects.clear();
g.appearance.items.push(blurred_fill);
}
s.execute("select.set", &json!({"ids": [graph]})).unwrap();
safe_mode::set_active(Some(safe_mode::Source::Flag));
let err = s.execute("effect.expandAppearance", &json!({})).unwrap_err().to_string();
safe_mode::set_active(None);
assert!(err.contains("a plug-in effect in the selection can't be expanded in Safe Mode"), "{err}");
}
/// In Safe Mode, a plug-in effect on a dimension selected with the art it measures does not stop