slint-ui/slint · error
window_adapter just initialized above
Error message
window_adapter just initialized above
What it means
`window_adapter_ref()` calls `try_window_adapter()` which lazily creates the window adapter, then unwraps `window_adapter.get()` expecting it to be initialized. The `expect` fires if `try_window_adapter()` returned `Ok` without actually installing an adapter into the `OnceCell` — a broken contract between the two calls, or a race/bug in the lazy-init code path. It is an internal invariant violation in the interpreter's component instance.
Solutions
- Check `top_level_type()` before asking for a window adapter — non-windowed roots may not have one
- Upgrade to a fixed Slint version; this panic indicates a violated init contract
- Avoid calling `window_adapter_ref()` on instances you did not `run()`/`show()`; use `try_window_adapter` semantics via the public API instead
- File a reproducer upstream if a windowed component still triggers it
Example fix
// before
let adapter = instance.window_adapter_ref()?;
// after
if instance.top_level_type() == i_slint_compiler::llr::TopLevelComponentType::Window {
let adapter = instance.window_adapter_ref()?;
} Defensive patterns
Strategy: validation
Validate before calling
if instance.top_level_type() == i_slint_compiler::llr::TopLevelComponentType::Window {
let adapter = instance.window_adapter_ref()?;
} Prevention
- Only request the window adapter for windowed roots
- Show/run the component before accessing window internals
- Keep interpreter and component-instance APIs on supported versions; report regressions upstream
When it happens
Trigger: Calling `ComponentInstance::window_adapter_ref()` when `try_window_adapter()` succeeds but leaves the `window_adapter` cell empty — typically after internal refactors of the lazy initialization, or when the component was instantiated without window support and the init path short-circuited incorrectly.
Common situations: Hit by interpreter users calling `window_adapter_ref()` on instances created for non-windowed roots or in headless/testing setups where adapter creation silently skipped installation.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Cannot get property
- Cannot invoke callback
- Cannot set callback
- Cannot set property
- Global was just valid
AI-assisted analysis of slint-ui/slint@3a7e700487 (2026-09-16).
Data as JSON: /api/errors/1910b6d038c0423c.
Report an issue: GitHub.
Appendix: source
Thrown at internal/interpreter/component.rs:298
global: &str,
name: &str,
handler: impl Fn(&[Value]) -> Value + 'static,
) -> Result<(), ()> {
public_api::set_global_callback(&self.0, global, name, Box::new(handler))
}
pub fn invoke_global(&self, global: &str, name: &str, args: &[Value]) -> Option<Value> {
public_api::invoke_global(&self.0, global, name, args)
}
/// Return a borrowed reference to the window adapter, creating one
/// through the backend selector if necessary. The returned reference
/// lives as long as the instance.
pub fn window_adapter_ref(
&self,
) -> Result<&i_slint_core::window::WindowAdapterRc, i_slint_core::api::PlatformError> {
self.0.try_window_adapter()?;
Ok(self.0.window_adapter.get().expect("window_adapter just initialized above"))
}
/// Whether the root inherits `Window` or a non-windowed type such as
/// `SystemTrayIcon`.
pub fn top_level_type(&self) -> i_slint_compiler::llr::TopLevelComponentType {
let unit = &self.0.root_sub_component.compilation_unit;
match self.0.public_component_index {
Some(idx) => unit.public_components[idx].top_level_type,
None => i_slint_compiler::llr::TopLevelComponentType::Window,
}
}
/// Definition this instance was created from.
pub fn definition(&self) -> ComponentDefinitionInner {
let public_index = self.0.public_component_index.unwrap_or(0.into());
ComponentDefinitionInner {
compilation_unit: self.0.root_sub_component.compilation_unit.clone(),
public_index,View on GitHub (pinned to 3a7e700487)