This commit is contained in:
elvis
2025-12-02 05:00:48 +01:00
parent 36e5acb1ad
commit ec87f96046
3 changed files with 10 additions and 2 deletions

View File

@ -28,7 +28,7 @@ A simple script is provided to check for errors during development at [`./reacti
In order to format the code in a uniform way run `cargo +nightly fmt`. In order to format the code in a uniform way run `cargo +nightly fmt`.
To run the program use `cargo r`; to run the release build use `cargo r --relase`. To run the program use `cargo r`; to run the release build use `cargo r --release`.
## Native Application ## Native Application

View File

@ -109,7 +109,9 @@ fn generate_to_evaluate(
let mut input_hashes = vec![]; let mut input_hashes = vec![];
match graph[n_id].user_data.template { match graph[n_id].user_data.template {
| NodeInstruction::SaveString | NodeInstruction::SaveSvg => { | NodeInstruction::SaveString |
NodeInstruction::SaveSvg |
NodeInstruction::SaveRasterization => {
res.push(n_id); res.push(n_id);
invalid_ids.insert(n_id); invalid_ids.insert(n_id);
outputs_cache.invalidate_outputs(graph, n_id); outputs_cache.invalidate_outputs(graph, n_id);

View File

@ -26,6 +26,9 @@ pub(crate) struct Svg {
impl Svg { impl Svg {
pub(crate) fn parse_dot_string(dot_str: &str) -> Result<Svg, String> { pub(crate) fn parse_dot_string(dot_str: &str) -> Result<Svg, String> {
if dot_str.is_empty() {
return Err("Dot string is empty".into());
}
let mut fontdb = fontdb::Database::new(); let mut fontdb = fontdb::Database::new();
fontdb.load_system_fonts(); fontdb.load_system_fonts();
@ -43,6 +46,9 @@ impl Svg {
gb.visit_graph(&g); gb.visit_graph(&g);
let mut graph = gb.get(); let mut graph = gb.get();
let mut svg = SVGWriter::new(); let mut svg = SVGWriter::new();
if graph.num_nodes() == 0 {
return Err("No nodes in dot graph".into());
}
graph.do_it(false, false, false, &mut svg); graph.do_it(false, false, false, &mut svg);
// convert svg to string // convert svg to string
let content = svg.finalize(); let content = svg.finalize();