mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 14:51:15 +00:00
Fix crash of the online editor
Component's get_item_ref has a life time attached to it, and in the interpreter we're having two vtable implementations, one for ErasedComponentBox and another generated one. The approach with as_pin_ref to transfer the lifetime to a reference to the trait object for the other vtable isn't working because as_pin_ref consumes the VRef and then takes the address of a temporary on the stack. Short of a cleaner solution, this patch circumvents the second vtable indirection and calls our extern "C" function directly.
This commit is contained in:
parent
3c79488637
commit
79bfa080c6
2 changed files with 4 additions and 15 deletions
|
@ -224,7 +224,10 @@ impl Component for ErasedComponentBox {
|
|||
self.borrow().as_ref().apply_layout(r)
|
||||
}
|
||||
fn get_item_ref<'a>(self: Pin<&'a Self>, index: usize) -> Pin<ItemRef<'a>> {
|
||||
vtable::VRef::as_pin_ref(self.get_ref().borrow()).get_item_ref(index)
|
||||
// We're having difficulties transferring the lifetime to a pinned reference
|
||||
// to the other ComponentVTable with the same life time. So skip the vtable
|
||||
// indirection and call our implementation directly.
|
||||
unsafe { get_item_ref(self.get_ref().borrow(), index) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue