slint-ui/slint · error
Cannot get property
Error message
Cannot get property {global_name}::{name}: {e} What it means
LiveComponent::get_global_property panics when the interpreter cannot read the requested property from the named global singleton. Since the return type is Value (not Result), an unresolvable global/property or type conversion error has no representation other than a panic.
Solutions
- Confirm the global is exported and the property is declared (and public) on it
- Ensure the LiveComponent compiled and instantiated successfully before reading globals
- Re-read after hot-reload only with names still present in the new .slint version
Example fix
// before
let v = live.get_global_property("Theme", "accent"); // global renamed to Palette
// after
let v = live.get_global_property("Palette", "accent"); Defensive patterns
Strategy: validation
Validate before calling
let known_globals: Vec<_> = instance.definition().globals().iter().map(|g| g.name.clone()).collect(); debug_assert!(known_globals.iter().any(|g| g == "Palette"));
Try / catch
// panic! is not catchable; ensure the instance compiled and the global exists first
assert!(instance.definition().globals().iter().any(|g| g.name == "Palette"));
let v = live.get_global_property("Palette", "accent"); Prevention
- Only read globals after successful component compilation/instantiation
- Cache global/property names from the ComponentDefinition rather than hardcoding
- Re-validate names after hot reloads
When it happens
Trigger: get_global_property with a global name not exported from the component, a property name missing on that global, or when the compiled instance was reloaded and globals were renamed.
Common situations: Reading a property before the component instance was successfully created; typos in global or property names; assuming a global exists that the designer removed from the .slint file.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Cannot invoke callback
- Cannot set callback
- Cannot set property
- Global was just valid
- root_component() called on a definition built without…
AI-assisted analysis of slint-ui/slint@3a7e700487 (2026-09-16).
Data as JSON: /api/errors/07456fcc5ed43700.
Report an issue: GitHub.
Appendix: source
Thrown at internal/live-preview/live_component.rs:224
self.callbacks.borrow_mut().insert(name.into(), callback.clone());
self.instance()
.set_callback(name, move |args| callback(args))
.unwrap_or_else(|e| panic!("Cannot set callback {name}: {e}"));
}
/// forward to set_global_property
pub fn set_global_property(&self, global_name: &str, name: &str, value: Value) {
self.properties.borrow_mut().insert(format!("{global_name}.{name}"), value.clone());
self.instance()
.set_global_property(global_name, name, value)
.unwrap_or_else(|e| panic!("Cannot set property {global_name}::{name}: {e}"))
}
/// forward to get_global_property
pub fn get_global_property(&self, global_name: &str, name: &str) -> Value {
self.instance()
.get_global_property(global_name, name)
.unwrap_or_else(|e| panic!("Cannot get property {global_name}::{name}: {e}"))
}
/// Forward to invoke_global
pub fn invoke_global(&self, global_name: &str, name: &str, args: &[Value]) -> Value {
self.instance()
.invoke_global(global_name, name, args)
.unwrap_or_else(|e| panic!("Cannot invoke callback {global_name}::{name}: {e}"))
}
/// Forward to set_global_callback
pub fn set_global_callback(
&self,
global_name: &str,
name: &str,
callback: Rc<dyn Fn(&[Value]) -> Value + 'static>,
) {
self.callbacks.borrow_mut().insert(format!("{global_name}.{name}"), callback.clone());
self.instance()View on GitHub (pinned to 3a7e700487)