From 531ce2a10e62ba731048c0d572b753fd05fdf401 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 15 Nov 2026 08:07:49 -0800 Subject: [PATCH] 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. --- crates/engine/src/cmd/effectcmd.rs | 7 ++++--- crates/engine/tests/plugin_safe_mode.rs | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/effectcmd.rs b/crates/engine/src/cmd/effectcmd.rs index 5ca2055178..625300cd25 100644 --- a/crates/engine/src/cmd/effectcmd.rs +++ b/crates/engine/src/cmd/effectcmd.rs @@ -1302,15 +1302,16 @@ fn expand_appearance(s: &mut Session, p: &Value) -> Result { 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 = 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(); diff --git a/crates/engine/tests/plugin_safe_mode.rs b/crates/engine/tests/plugin_safe_mode.rs index 8829c056b3..9ff0d0668a 100644 --- a/crates/engine/tests/plugin_safe_mode.rs +++ b/crates/engine/tests/plugin_safe_mode.rs @@ -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