slint-ui/slint · error

Cannot set callback {global_name}::{name}: {e}

Error message

Cannot set callback {global_name}::{name}: {e}

What it means

Error "Cannot set callback {global_name}::{name}: {e}" thrown in slint-ui/slint.

Source

Thrown at internal/live-preview/live_component.rs:244

    /// 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()
            .set_global_callback(global_name, name, move |args| callback(args))
            .unwrap_or_else(|e| panic!("Cannot set callback {global_name}::{name}: {e}"));
    }
}

enum WatcherState {
    Starting,
    /// The file system watcher notified the main thread of a change
    Changed,
    /// The main thread is waiting for the next event
    Waiting(Waker),
}

struct Watcher {
    // (wouldn't need to be an option if new_cyclic() could return errors)
    watcher: Option<FileWatcher>,
    state: WatcherState,
}

impl Watcher {

View on GitHub (pinned to 3fd8f2ec03)

Solutions

  1. Check the nested error and match the callback handler's signature to the declaration.
  2. Verify the global and callback names.

When it happens

Trigger: Thrown at internal/live-preview/live_component.rs:244 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of slint-ui/slint@3fd8f2ec03 (2026-08-19). Data as JSON: /api/errors/02ffc662ac1fbd00. Report an issue: GitHub.