Upgrade to PyO3 0.22

This commit is contained in:
Simon Hausmann 2025-04-03 09:26:14 +02:00 committed by Simon Hausmann
parent ffce61ca97
commit 9253af05b1
3 changed files with 12 additions and 9 deletions

View file

@ -55,11 +55,12 @@ slint-interpreter = { workspace = true, features = [
"internal",
] }
i-slint-compiler = { workspace = true }
pyo3 = { version = "0.21.0", features = [
pyo3 = { version = "0.22", features = [
"extension-module",
"indexmap",
"chrono",
"abi3-py310",
"gil-refs",
] }
indexmap = { version = "2.1.0" }
chrono = "0.4"

View file

@ -155,11 +155,13 @@ impl i_slint_core::model::Model for PyModelShared {
}
impl PyModelShared {
pub fn rust_into_js_model(model: &ModelRc<slint_interpreter::Value>) -> Option<PyObject> {
model
.as_any()
.downcast_ref::<PyModelShared>()
.and_then(|rust_model| rust_model.self_ref.borrow().clone())
pub fn rust_into_js_model<'py>(
model: &ModelRc<slint_interpreter::Value>,
py: Python<'py>,
) -> Option<PyObject> {
model.as_any().downcast_ref::<PyModelShared>().and_then(|rust_model| {
rust_model.self_ref.borrow().as_ref().map(|obj| obj.clone_ref(py))
})
}
}

View file

@ -42,7 +42,7 @@ impl ToPyObject for PyValueRef<'_> {
crate::image::PyImage::from(image).into_py(py)
}
slint_interpreter::Value::Model(model) => {
crate::models::PyModelShared::rust_into_js_model(model)
crate::models::PyModelShared::rust_into_js_model(model, py)
.unwrap_or_else(|| crate::models::ReadOnlyRustModel::from(model).into_py(py))
}
slint_interpreter::Value::Struct(structval) => {
@ -59,8 +59,8 @@ impl ToPyObject for PyValueRef<'_> {
}
}
impl FromPyObject<'_> for PyValue {
fn extract(ob: &PyAny) -> PyResult<Self> {
impl<'py> FromPyObject<'py> for PyValue {
fn extract_bound(ob: &Bound<'py, PyAny>) -> PyResult<Self> {
if ob.is_none() {
return Ok(slint_interpreter::Value::Void.into());
}