slint-ui/slint · error
The window shouldn't be initialized before this call
Error message
The window shouldn't be initialized before this call
What it means
Error "The window shouldn't be initialized before this call" thrown in slint-ui/slint.
Source
Thrown at internal/compiler/generator/rust.rs:646
// `create_window_from_context` is only invoked from a Window-rooted
// public component's `new_with_context`, and `maybe_window_adapter_impl`
// is only invoked from per-tree `register_item_tree` / PinnedDrop hooks
// — both gated out for tray-only units. Emit them only when something
// actually calls them; otherwise `#![deny(warnings)]` builds (e.g.
// test-driver-rust with `--features build-time`) trip on dead_code.
// `window_adapter_impl` / `window_adapter_ref` are kept unconditionally
// because expression codegen (layout-info, font metrics) still
// references them on every tree.
let optional_window_adapter_helpers = needs_window_adapter.then(|| {
quote!(
#[cfg(#experimental)]
fn create_window_from_context(&self, ctx: sp::SlintContext) -> sp::Result<(), slint::PlatformError> {
let adapter = ctx.platform().create_window_adapter()?;
sp::WindowInner::from_pub(adapter.window()).set_context(ctx);
let root_rc = self.root_item_tree_weak.upgrade().unwrap();
sp::WindowInner::from_pub(adapter.window()).set_component(&root_rc);
#apply_constant_scale_factor
self.window_adapter.set(adapter).map_err(|_|()).expect("The window shouldn't be initialized before this call");
sp::Ok(())
}
#[cfg(#experimental)]
fn create_window_from_existing(&self, window: &slint::Window) -> sp::Result<(), slint::PlatformError> {
let adapter = sp::WindowInner::from_pub(window).window_adapter();
let root_rc = self.root_item_tree_weak.upgrade().unwrap();
sp::WindowInner::from_pub(adapter.window()).set_component(&root_rc);
#apply_constant_scale_factor
self.window_adapter.set(adapter).map_err(|_|()).expect("The window shouldn't be initialized before this call");
sp::Ok(())
}
fn maybe_window_adapter_impl(&self) -> sp::Option<sp::Rc<dyn sp::WindowAdapter>> {
self.window_adapter.get().cloned()
}
)
});View on GitHub (pinned to 3fd8f2ec03)
Solutions
- Internal compiler error: report the .slint code triggering this assertion.
- Regenerate the Rust code from a clean build.
When it happens
Trigger: Thrown at internal/compiler/generator/rust.rs:646 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of slint-ui/slint@3fd8f2ec03 (2026-08-19).
Data as JSON: /api/errors/f029b01d877b667d.
Report an issue: GitHub.