Handle empty paths in PathBuilder::get_current_point()

The case of calling get_current_point() on empty paths has not been
handled and caused panics.
This commit is contained in:
pylbrecht 2019-10-31 19:11:56 +01:00
parent 606ad20544
commit b8b33788b6
3 changed files with 15 additions and 17 deletions

View file

@ -189,9 +189,9 @@ impl GenericPathBuilder for azure_hl::PathBuilder {
anticlockwise,
);
}
fn get_current_point(&mut self) -> Point2D<f32> {
fn get_current_point(&mut self) -> Option<Point2D<f32>> {
let AzPoint { x, y } = azure_hl::PathBuilder::get_current_point(self);
Point2D::new(x as f32, y as f32)
Some(Point2D::new(x as f32, y as f32))
}
fn line_to(&mut self, point: Point2D<f32>) {
azure_hl::PathBuilder::line_to(self, point as Point2D<AzFloat>);