{"record":{"id":"76388938368b6f40","repo":"slint-ui/slint","slug":"cannot-set-callback-name-e","errorCode":null,"errorMessage":"Cannot set callback {name}: {e}","messagePattern":"Cannot set callback (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/live-preview/live_component.rs","lineNumber":152,"sourceCode":"    pub fn reload_properties_and_callbacks(&self) {\n        // Set the properties\n        for (name, value) in self.properties.borrow_mut().iter() {\n            if let Some((global, prop)) = name.split_once('.') {\n                self.instance()\n                    .set_global_property(global, prop, value.clone())\n                    .unwrap_or_else(|e| panic!(\"Cannot set property {name}: {e}\"));\n            } else {\n                self.instance()\n                    .set_property(name, value.clone())\n                    .unwrap_or_else(|e| panic!(\"Cannot set property {name}: {e}\"));\n            }\n        }\n        for (name, callback) in self.callbacks.borrow_mut().iter() {\n            let callback = callback.clone();\n            if let Some((global, prop)) = name.split_once('.') {\n                self.instance()\n                    .set_global_callback(global, prop, move |args| callback(args))\n                    .unwrap_or_else(|e| panic!(\"Cannot set callback {name}: {e}\"));\n            } else {\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\n        eprintln!(\n            \"Reloaded component {} from {}\",\n            self.component_name.as_deref().unwrap_or(\"<default>\"),\n            self.file_name.display()\n        );\n    }\n\n    /// Set a hook that runs after each successful reload, receiving the new instance.\n    pub fn set_post_reload_hook(&mut self, hook: impl Fn(&ComponentInstance) + 'static) {\n        self.post_reload_hook = Some(Box::new(hook));\n    }","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/slint-ui/slint/blob/3a7e700487dc74d404cad0726378053ab763d4e0/internal/live-preview/live_component.rs#L134-L170","documentation":"Panic in live-preview's reload_properties_and_callbacks when set_global_callback fails after a reload. A callback previously registered on a global singleton could not be re-attached to the new component instance.","triggerScenarios":"Live-preview reload where a global callback name (containing a '.') no longer exists on the reloaded component or its signature changed.","commonSituations":"Renaming or deleting a global callback during live editing; changing a callback's parameter types; moving the callback out of the global in the .slint source.","solutions":["Keep the global callback declaration (name and signature) unchanged across the reload.","Inspect {e} to find the exact missing global/callback and fix the .slint source or re-register with the new name.","Restart the live preview session to drop stale callback registrations.","Re-set callbacks after reload rather than relying on automatic re-registration when signatures change."],"exampleFix":"// before (global callback removed during reload)\nexport global Actions { callback save(); }\n// after: keep it declared or update registrations\nexport global Actions { callback save(); } // and re-register set_global_callback(\"Actions\", \"save\", ...)","handlingStrategy":"fallback","validationCode":"// Confirm the global and callback exist before re-registering\n// instance.definition().globals() / global callback lists","typeGuard":null,"tryCatchPattern":"if let Err(e) = instance.set_global_callback(global, prop, handler) {\n    eprintln!(\"skipping stale callback {name}: {e}\");\n}","preventionTips":["Keep global callback names and signatures stable across reloads.","Re-register callbacks explicitly after intentional renames.","Restart the preview session after deleting globals."],"tags":["live-preview","hot-reload","callback","panic"],"backgroundTag":"invalid-state-transition","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"}