Introduce Window::try_dispatch_event (#7313)

That is the same as Window::dispatch_event, but it reports an error
instead of panicking
This commit is contained in:
Olivier Goffart 2025-01-09 19:39:38 +01:00 committed by GitHub
parent 19bfe926d2
commit cfbcf0b1d7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 137 additions and 102 deletions

View file

@ -363,7 +363,7 @@ fn generate_shared_globals(
let apply_constant_scale_factor = if !compiler_config.const_scale_factor.approx_eq(&1.0) {
let factor = compiler_config.const_scale_factor as f32;
Some(
quote!(adapter.window().dispatch_event(slint::platform::WindowEvent::ScaleFactorChanged{ scale_factor: #factor });),
quote!(adapter.window().try_dispatch_event(slint::platform::WindowEvent::ScaleFactorChanged{ scale_factor: #factor })?;),
)
} else {
None