{"record":{"id":"1910b6d038c0423c","repo":"slint-ui/slint","slug":"window-adapter-just-initialized-above","errorCode":null,"errorMessage":"window_adapter just initialized above","messagePattern":"window_adapter just initialized above","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/interpreter/component.rs","lineNumber":298,"sourceCode":"        global: &str,\n        name: &str,\n        handler: impl Fn(&[Value]) -> Value + 'static,\n    ) -> Result<(), ()> {\n        public_api::set_global_callback(&self.0, global, name, Box::new(handler))\n    }\n\n    pub fn invoke_global(&self, global: &str, name: &str, args: &[Value]) -> Option<Value> {\n        public_api::invoke_global(&self.0, global, name, args)\n    }\n\n    /// Return a borrowed reference to the window adapter, creating one\n    /// through the backend selector if necessary. The returned reference\n    /// lives as long as the instance.\n    pub fn window_adapter_ref(\n        &self,\n    ) -> Result<&i_slint_core::window::WindowAdapterRc, i_slint_core::api::PlatformError> {\n        self.0.try_window_adapter()?;\n        Ok(self.0.window_adapter.get().expect(\"window_adapter just initialized above\"))\n    }\n\n    /// Whether the root inherits `Window` or a non-windowed type such as\n    /// `SystemTrayIcon`.\n    pub fn top_level_type(&self) -> i_slint_compiler::llr::TopLevelComponentType {\n        let unit = &self.0.root_sub_component.compilation_unit;\n        match self.0.public_component_index {\n            Some(idx) => unit.public_components[idx].top_level_type,\n            None => i_slint_compiler::llr::TopLevelComponentType::Window,\n        }\n    }\n\n    /// Definition this instance was created from.\n    pub fn definition(&self) -> ComponentDefinitionInner {\n        let public_index = self.0.public_component_index.unwrap_or(0.into());\n        ComponentDefinitionInner {\n            compilation_unit: self.0.root_sub_component.compilation_unit.clone(),\n            public_index,","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/interpreter/component.rs#L280-L316","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nlet adapter = instance.window_adapter_ref()?;\n// after\nif instance.top_level_type() == i_slint_compiler::llr::TopLevelComponentType::Window {\n    let adapter = instance.window_adapter_ref()?;\n}","handlingStrategy":"validation","validationCode":"if instance.top_level_type() == i_slint_compiler::llr::TopLevelComponentType::Window {\n    let adapter = instance.window_adapter_ref()?;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["interpreter","rust","panic","window"],"backgroundTag":"internal-invariant-violation","analyzedSha":"3a7e700487dc74d404cad0726378053ab763d4e0","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}