mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-03 18:29:09 +00:00
Python: Don't panic when invoking a python callback fails
Instead, log a message and return.
This commit is contained in:
parent
80593b4f71
commit
a29cc4ddf2
1 changed files with 14 additions and 5 deletions
|
@ -340,11 +340,20 @@ impl GcVisibleCallbacks {
|
|||
let callable = callables.get(&name).unwrap();
|
||||
Python::with_gil(|py| {
|
||||
let py_args = PyTuple::new(py, args.iter().map(|v| PyValue(v.clone())));
|
||||
let result =
|
||||
callable.call(py, py_args, None).expect("invoking python callback failed");
|
||||
let pv: PyValue = result
|
||||
.extract(py)
|
||||
.expect("unable to convert python callback result to slint interpreter value");
|
||||
let result = match callable.call(py, py_args, None) {
|
||||
Ok(result) => result,
|
||||
Err(err) => {
|
||||
eprintln!("Python: Invoking python callback threw an exception: {err}");
|
||||
return Value::Void;
|
||||
}
|
||||
};
|
||||
let pv: PyValue = match result.extract(py) {
|
||||
Ok(value) => value,
|
||||
Err(err) => {
|
||||
eprintln!("Python: Unable to convert return value of Python callback to Slint value: {err}");
|
||||
return Value::Void;
|
||||
}
|
||||
};
|
||||
pv.0
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue