{"record":{"id":"a48802faef1d5819","repo":"slint-ui/slint","slug":"cannot-invoke-callback-global-name-name-e","errorCode":null,"errorMessage":"Cannot invoke callback {global_name}::{name}: {e}","messagePattern":"Cannot invoke callback (.+?)::(.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/live-preview/live_component.rs","lineNumber":231,"sourceCode":"    pub fn set_global_property(&self, global_name: &str, name: &str, value: Value) {\n        self.properties.borrow_mut().insert(format!(\"{global_name}.{name}\"), value.clone());\n        self.instance()\n            .set_global_property(global_name, name, value)\n            .unwrap_or_else(|e| panic!(\"Cannot set property {global_name}::{name}: {e}\"))\n    }\n\n    /// forward to get_global_property\n    pub fn get_global_property(&self, global_name: &str, name: &str) -> Value {\n        self.instance()\n            .get_global_property(global_name, name)\n            .unwrap_or_else(|e| panic!(\"Cannot get property {global_name}::{name}: {e}\"))\n    }\n\n    /// Forward to invoke_global\n    pub fn invoke_global(&self, global_name: &str, name: &str, args: &[Value]) -> Value {\n        self.instance()\n            .invoke_global(global_name, name, args)\n            .unwrap_or_else(|e| panic!(\"Cannot invoke callback {global_name}::{name}: {e}\"))\n    }\n\n    /// Forward to set_global_callback\n    pub fn set_global_callback(\n        &self,\n        global_name: &str,\n        name: &str,\n        callback: Rc<dyn Fn(&[Value]) -> Value + 'static>,\n    ) {\n        self.callbacks.borrow_mut().insert(format!(\"{global_name}.{name}\"), callback.clone());\n        self.instance()\n            .set_global_callback(global_name, name, move |args| callback(args))\n            .unwrap_or_else(|e| panic!(\"Cannot set callback {global_name}::{name}: {e}\"));\n    }\n}\n\nenum WatcherState {\n    Starting,","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/live-preview/live_component.rs#L213-L249","documentation":"LiveComponent::invoke_global panics when the interpreter fails to invoke a callback declared on a global singleton. The method returns Value directly, so any interpreter error (unknown global/callback, wrong argument count/types) is surfaced as a panic instead of a Result.","triggerScenarios":"invoke_global(global_name, name, args) where the global or callback name does not resolve, or the args slice does not match the callback's declared parameter types/arity.","commonSituations":"Invoking a callback with missing or extra arguments; calling a component-root callback via invoke_global instead of set_callback-wrapped invocation; stale names after live-reload.","solutions":["Match the args slice length and Value types to the callback's declared signature","Verify the callback is declared on the exported global (not the root element)","After a .slint hot-reload, re-look-up callback names before invoking"],"exampleFix":"// before\nlive.invoke_global(\"Logic\", \"compute\", &[]); // callback expects one int arg\n// after\nlive.invoke_global(\"Logic\", \"compute\", &[Value::Number(42.0)]);","handlingStrategy":"validation","validationCode":"fn callback_arity(declared: usize, args: &[Value]) -> bool { declared == args.len() }\n// compare against the callback's declared parameter count from the ComponentDefinition before invoking","typeGuard":null,"tryCatchPattern":"// panic! is not catchable; check name and argument count before invoke\nif args.len() == declared_param_count {\n    live.invoke_global(\"Logic\", \"compute\", args);\n}","preventionTips":["Build argument slices from typed helpers so arity/type always match","Keep global callback signatures in sync with the .slint via tests","Refresh name lookups after live-reload before invoking"],"tags":["rust","live-preview","interpreter","panic"],"backgroundTag":"entity-not-found","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"}