Don't panic in the generated rust ComponentHandle::window()

It can panic if lazily constructing the window adapter.
Make sure it is actially not lasily constructed, we don't need lazy constructor when not embedding anyway.
This commit is contained in:
Olivier Goffart 2025-01-15 20:42:06 +01:00
parent 62d9f8b13f
commit 9d1be5209c

View file

@ -291,6 +291,8 @@ fn generate_public_component(
#init_bundle_translations
inner.globals.get().unwrap().init();
#inner_component_id::user_init(sp::VRc::map(inner.clone(), |x| x));
// ensure that the window exist as this point so further call to window() don't panic
inner.globals.get().unwrap().window_adapter_ref()?;
core::result::Result::Ok(Self(inner))
}