From fe0f8b5e5264c699115418cc0d293d74e30e6ace Mon Sep 17 00:00:00 2001 From: Ilya Zlobintsev Date: Fri, 16 Aug 2024 09:18:15 +0300 Subject: [PATCH] fix: avoid crashing on non-numeric input in fan curve editor --- .../thermals_page/fan_curve_frame/point_adjustment.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lact-gui/src/app/root_stack/thermals_page/fan_curve_frame/point_adjustment.rs b/lact-gui/src/app/root_stack/thermals_page/fan_curve_frame/point_adjustment.rs index 334ebdb..49a7ce8 100644 --- a/lact-gui/src/app/root_stack/thermals_page/fan_curve_frame/point_adjustment.rs +++ b/lact-gui/src/app/root_stack/thermals_page/fan_curve_frame/point_adjustment.rs @@ -34,7 +34,7 @@ impl PointAdjustment { temperature_selector.connect_input(|spin| { let text = spin.text(); let temp = text.trim_end_matches("°C"); - Some(Ok(temp.parse::().unwrap())) + Some(Ok(temp.parse::().unwrap_or_else(|_| spin.value()))) }); temperature_selector.connect_output(|spin| { let text = format!("{}°C", spin.value_as_int()); @@ -45,7 +45,10 @@ impl PointAdjustment { ratio_selector.connect_input(|spin| { let text = spin.text(); let percentage = text.trim_end_matches('%'); - Some(Ok(percentage.parse::().unwrap() / 100.0)) + Some(Ok(percentage + .parse::() + .map(|value| value / 100.0) + .unwrap_or_else(|_| spin.value()))) }); ratio_selector.connect_output(|spin| { let value = spin.value();