Skip to content

Commit c137e44

Browse files
kythyriaKeavon
andauthored
Fix the 'Bounding Box' node crashing on empty or single-point vector data input (#2529)
* Make Bounding Box have empty output on empty input Fixes a crash when using the text tool and the Text node is connected to a Bounding Box node. * Use .map().unwrap_or_default() --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
1 parent 93f7004 commit c137e44

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

node-graph/gcore/src/vector/vector_nodes.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,10 @@ async fn bounding_box(_: impl Ctx, vector_data: VectorDataTable) -> VectorDataTa
942942
let vector_data_transform = vector_data.transform();
943943
let vector_data = vector_data.one_instance().instance;
944944

945-
let bounding_box = vector_data.bounding_box_with_transform(vector_data_transform).unwrap();
946-
let mut result = VectorData::from_subpath(Subpath::new_rect(bounding_box[0], bounding_box[1]));
945+
let mut result = vector_data
946+
.bounding_box_with_transform(vector_data_transform)
947+
.map(|bounding_box| VectorData::from_subpath(Subpath::new_rect(bounding_box[0], bounding_box[1])))
948+
.unwrap_or_default();
947949
result.style = vector_data.style.clone();
948950
result.style.set_stroke_transform(DAffine2::IDENTITY);
949951

0 commit comments

Comments
 (0)