mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-01 20:31:27 +00:00
Convert None to Void correctly
This commit is contained in:
parent
82c2728cfd
commit
08461d7b32
2 changed files with 8 additions and 0 deletions
|
|
@ -84,6 +84,7 @@ def test_callbacks():
|
|||
test-callback(value) => {
|
||||
return "local " + value;
|
||||
}
|
||||
callback void-callback();
|
||||
}
|
||||
""", "")
|
||||
assert compdef != None
|
||||
|
|
@ -106,3 +107,6 @@ def test_callbacks():
|
|||
|
||||
instance.set_global_callback("TestGlobal", "globallogic", lambda x: "python global " + x)
|
||||
assert instance.invoke_global("TestGlobal", "globallogic", "foo") == "python global foo"
|
||||
|
||||
instance.set_callback("void-callback", lambda : None)
|
||||
instance.invoke("void-callback")
|
||||
|
|
|
|||
|
|
@ -39,6 +39,10 @@ impl ToPyObject for PyValue {
|
|||
|
||||
impl FromPyObject<'_> for PyValue {
|
||||
fn extract(ob: &PyAny) -> PyResult<Self> {
|
||||
if ob.is_none() {
|
||||
return Ok(slint_interpreter::Value::Void.into());
|
||||
}
|
||||
|
||||
Ok(PyValue(
|
||||
ob.extract::<bool>()
|
||||
.map(|b| slint_interpreter::Value::Bool(b))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue