From ab49c451e64ee47c8f6386e34403126b9556a6dd Mon Sep 17 00:00:00 2001 From: Norbert Nemec Date: Tue, 9 Mar 2021 13:14:33 +0100 Subject: [PATCH] DragValue: fix crash for speed==0.0 --- egui/src/widgets/drag_value.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/egui/src/widgets/drag_value.rs b/egui/src/widgets/drag_value.rs index f9b39e63aa1..eef12add282 100644 --- a/egui/src/widgets/drag_value.rs +++ b/egui/src/widgets/drag_value.rs @@ -198,7 +198,7 @@ impl<'a> Widget for DragValue<'a> { let value = get(&mut get_set_value); let value = clamp(value, clamp_range.clone()); 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 auto_decimals = clamp(auto_decimals, min_decimals..=max_decimals); let value_text = if value == 0.0 {