Fix crash from gradients with bounds of zero (#1950)

Fix zero bound gradient
This commit is contained in:
James Lindsay 2024-09-02 00:12:02 +01:00 committed by GitHub
parent 9adc640f19
commit 444929adbf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 2 deletions

View File

@ -163,8 +163,12 @@ impl Gradient {
stop.push_str(" />")
}
let mod_gradient = transformed_bound_transform.inverse();
let mod_points = mod_gradient.inverse() * transformed_bound_transform.inverse() * updated_transform;
let mod_gradient = if transformed_bound_transform.matrix2.determinant() != 0. {
transformed_bound_transform.inverse()
} else {
DAffine2::IDENTITY // Ignore if the transform cannot be inverted (the bounds are zero). See issue #1944.
};
let mod_points = updated_transform;
let start = mod_points.transform_point2(self.start);
let end = mod_points.transform_point2(self.end);