{"record":{"id":"5ee42073a3e05c90","repo":"slint-ui/slint","slug":"cannot-invoke-callback-name-e","errorCode":null,"errorMessage":"Cannot invoke callback {name}: {e}","messagePattern":"Cannot invoke callback (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/live-preview/live_component.rs","lineNumber":201,"sourceCode":"    pub fn set_property(&self, name: &str, value: Value) {\n        self.properties.borrow_mut().insert(name.into(), value.clone());\n        self.instance()\n            .set_property(name, value)\n            .unwrap_or_else(|e| panic!(\"Cannot set property {name}: {e}\"))\n    }\n\n    /// Forward to get_property\n    pub fn get_property(&self, name: &str) -> Value {\n        self.instance()\n            .get_property(name)\n            .unwrap_or_else(|e| panic!(\"Cannot get property {name}: {e}\"))\n    }\n\n    /// Forward to invoke\n    pub fn invoke(&self, name: &str, args: &[Value]) -> Value {\n        self.instance()\n            .invoke(name, args)\n            .unwrap_or_else(|e| panic!(\"Cannot invoke callback {name}: {e}\"))\n    }\n\n    /// Forward to set_callback\n    pub fn set_callback(&self, name: &str, callback: Rc<dyn Fn(&[Value]) -> Value + 'static>) {\n        self.callbacks.borrow_mut().insert(name.into(), callback.clone());\n        self.instance()\n            .set_callback(name, move |args| callback(args))\n            .unwrap_or_else(|e| panic!(\"Cannot set callback {name}: {e}\"));\n    }\n\n    /// forward to set_global_property\n    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","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/live-preview/live_component.rs#L183-L219","documentation":"LiveComponent.invoke forwards a named callback invocation to the compiled component instance and panics on error. This fires at runtime in the live-preview tool when invoking a callback fails — most often the callback name doesn't exist on the component (typo or stale property panel state), the argument Values don't match the callback signature, or the callback itself errored. It's a fail-fast guard for tooling, replacing a silent swallowed error.","triggerScenarios":"Calling LiveComponent::invoke with a callback name not declared on the component, wrong number of arguments, or argument types not matching the callback signature.","commonSituations":"Automated tests/tooling invoking callbacks after the .slint file was edited; invoking a handler that only exists on a sub-element; passing a string where the callback expects an int.","solutions":["Verify the callback is declared on the top-level component with a matching signature.","Check argument count and types against the callback declaration.","Use the raw instance invoke (Result-returning) if you need graceful failure handling.","Re-load the component after edits and refresh the list of callable callbacks."],"exampleFix":"// before\nlive.invoke(\"on_clicked\", &[]); // not a declared callback\n// after\nlive.invoke(\"clicked\", &[]); // match declared callback clicked();","handlingStrategy":"try-catch","validationCode":"// Verify the callback exists and arity matches before invoking\n// if instance.definition().callbacks(name).iter().any(|c| c.name == cb && c.args.len() == n) { ... }","typeGuard":null,"tryCatchPattern":"match instance.invoke(name, args) {\n    Ok(v) => v,\n    Err(e) => { eprintln!(\"invoke {name} failed: {e}\"); Value::default() }\n}","preventionTips":["Invoke only callbacks declared on the top-level component.","Match argument count and Value types to the callback signature.","Refresh the callback list after every hot reload."],"tags":["live-preview","callback","invocation-failure","panic"],"backgroundTag":"record-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"}