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>
This commit is contained in:
parent
93f7004ece
commit
c137e44b71
|
|
@ -942,8 +942,10 @@ async fn bounding_box(_: impl Ctx, vector_data: VectorDataTable) -> VectorDataTa
|
||||||
let vector_data_transform = vector_data.transform();
|
let vector_data_transform = vector_data.transform();
|
||||||
let vector_data = vector_data.one_instance().instance;
|
let vector_data = vector_data.one_instance().instance;
|
||||||
|
|
||||||
let bounding_box = vector_data.bounding_box_with_transform(vector_data_transform).unwrap();
|
let mut result = vector_data
|
||||||
let mut result = VectorData::from_subpath(Subpath::new_rect(bounding_box[0], bounding_box[1]));
|
.bounding_box_with_transform(vector_data_transform)
|
||||||
|
.map(|bounding_box| VectorData::from_subpath(Subpath::new_rect(bounding_box[0], bounding_box[1])))
|
||||||
|
.unwrap_or_default();
|
||||||
result.style = vector_data.style.clone();
|
result.style = vector_data.style.clone();
|
||||||
result.style.set_stroke_transform(DAffine2::IDENTITY);
|
result.style.set_stroke_transform(DAffine2::IDENTITY);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue