mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-04 18:58:36 +00:00
Fix compilation when dividing by zero at compile time
Rust would have panicked and C++ generated wrong code. CC #3982
This commit is contained in:
parent
8a841405c8
commit
6195fc8567
3 changed files with 18 additions and 8 deletions
|
@ -2524,7 +2524,10 @@ fn compile_expression(expr: &llr::Expression, ctx: &EvaluationContext) -> String
|
|||
format!(r#"slint::SharedString(u8"{}")"#, escape_string(s.as_str()))
|
||||
}
|
||||
Expression::NumberLiteral(num) => {
|
||||
if *num > 1_000_000_000. {
|
||||
if !num.is_finite() {
|
||||
// just print something
|
||||
"0.0".to_string()
|
||||
} else if num.abs() > 1_000_000_000. {
|
||||
// If the numbers are too big, decimal notation will give too many digit
|
||||
format!("{:+e}", num)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue