mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-01 14:21:16 +00:00
Cpp: Add a self_weak to repeated components
The main struct has it, and sub-components should have it, too.
This commit is contained in:
parent
ba96e8570f
commit
a2839e03c2
2 changed files with 13 additions and 0 deletions
|
@ -566,6 +566,8 @@ public:
|
||||||
auto &c = inner->data[i];
|
auto &c = inner->data[i];
|
||||||
if (!c.ptr) {
|
if (!c.ptr) {
|
||||||
c.ptr = { vtable::VRc<private_api::ComponentVTable, C>::make(parent) };
|
c.ptr = { vtable::VRc<private_api::ComponentVTable, C>::make(parent) };
|
||||||
|
const_cast<C *>(&**c.ptr)->self_weak =
|
||||||
|
vtable::VWeak<private_api::ComponentVTable, C>(*c.ptr);
|
||||||
}
|
}
|
||||||
if (c.state == RepeaterInner::State::Dirty) {
|
if (c.state == RepeaterInner::State::Dirty) {
|
||||||
(*c.ptr)->update_data(i, m->row_data(i));
|
(*c.ptr)->update_data(i, m->row_data(i));
|
||||||
|
|
|
@ -827,6 +827,17 @@ fn generate_component(
|
||||||
}),
|
}),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
component_struct.members.push((
|
||||||
|
Access::Public,
|
||||||
|
Declaration::Var(Var {
|
||||||
|
ty: format!(
|
||||||
|
"vtable::VWeak<sixtyfps::private_api::ComponentVTable, {}>",
|
||||||
|
component_id
|
||||||
|
),
|
||||||
|
name: "self_weak".into(),
|
||||||
|
..Var::default()
|
||||||
|
}),
|
||||||
|
));
|
||||||
component_struct.members.push((
|
component_struct.members.push((
|
||||||
Access::Private,
|
Access::Private,
|
||||||
Declaration::Var(Var {
|
Declaration::Var(Var {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue