DragValue: fix crash for speed==0.0 (#216)

This commit is contained in:
Norbert Nemec 2021-03-09 19:06:04 +01:00 committed by GitHub
parent f07f9bf5bd
commit 6fb4e19e9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -198,7 +198,7 @@ impl<'a> Widget for DragValue<'a> {
let value = get(&mut get_set_value); let value = get(&mut get_set_value);
let value = clamp(value, clamp_range.clone()); let value = clamp(value, clamp_range.clone());
let aim_rad = ui.input().aim_radius() as f64; let aim_rad = ui.input().aim_radius() as f64;
let auto_decimals = (aim_rad / speed.abs()).log10().ceil().at_least(0.0) as usize; let auto_decimals = clamp((aim_rad / speed.abs()).log10().ceil(), 0.0..=15.0) as usize;
let max_decimals = max_decimals.unwrap_or(auto_decimals + 2); let max_decimals = max_decimals.unwrap_or(auto_decimals + 2);
let auto_decimals = clamp(auto_decimals, min_decimals..=max_decimals); let auto_decimals = clamp(auto_decimals, min_decimals..=max_decimals);
let value_text = if value == 0.0 { let value_text = if value == 0.0 {