Fix crash on NaN or infinite graph value (#1318)

This commit is contained in:
Lucas Baumann 2025-05-13 23:12:06 +02:00 committed by GitHub
parent 20d0997636
commit e953141fa9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View file

@ -9,6 +9,7 @@ All notable changes to eww will be listed here, starting at changes since versio
Attempting to index in an empty JSON string (`'""'`) is now an error. Attempting to index in an empty JSON string (`'""'`) is now an error.
### Fixes ### Fixes
- Fix crash on NaN or infinite graph value (By: luca3s)
- Re-enable some scss features (By: w-lfchen) - Re-enable some scss features (By: w-lfchen)
- Fix and refactor nix flake (By: w-lfchen) - Fix and refactor nix flake (By: w-lfchen)
- Fix remove items from systray (By: vnva) - Fix remove items from systray (By: vnva)

View file

@ -1252,7 +1252,14 @@ fn build_graph(bargs: &mut BuilderArgs) -> Result<super::graph::Graph> {
let w = super::graph::Graph::new(); let w = super::graph::Graph::new();
def_widget!(bargs, _g, w, { def_widget!(bargs, _g, w, {
// @prop value - the value, between 0 - 100 // @prop value - the value, between 0 - 100
prop(value: as_f64) { w.set_property("value", value); }, prop(value: as_f64) {
if value.is_nan() || value.is_infinite() {
return Err(DiagError(gen_diagnostic!(
format!("Graph's value should never be NaN or infinite")
)).into());
}
w.set_property("value", value);
},
// @prop thickness - the thickness of the line // @prop thickness - the thickness of the line
prop(thickness: as_f64) { w.set_property("thickness", thickness); }, prop(thickness: as_f64) { w.set_property("thickness", thickness); },
// @prop time-range - the range of time to show // @prop time-range - the range of time to show