mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-08-03 21:08:18 +00:00
Work around unwrap crash
This commit is contained in:
parent
a1ce796d94
commit
158f18df0d
1 changed files with 4 additions and 1 deletions
|
@ -519,7 +519,10 @@ impl HandleId {
|
|||
|
||||
/// Calculate the magnitude of the handle from the anchor.
|
||||
pub fn length(self, vector_data: &VectorData) -> f64 {
|
||||
let anchor_position = self.to_manipulator_point().get_anchor_position(vector_data).unwrap();
|
||||
let Some(anchor_position) = self.to_manipulator_point().get_anchor_position(vector_data) else {
|
||||
// TODO: This was previously an unwrap which was encountered, so this is a temporary way to avoid a crash
|
||||
return 0.;
|
||||
};
|
||||
let handle_position = self.to_manipulator_point().get_position(vector_data);
|
||||
handle_position.map(|pos| (pos - anchor_position).length()).unwrap_or(f64::MAX)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue