mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 06:41:14 +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
|
@ -296,11 +296,6 @@ impl<'a, T: ?Sized + VTableMeta> VRef<'a, T> {
|
|||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Return a Pin reference to the target, with the same lifetime
|
||||
pub fn as_pin_ref(this: Pin<Self>) -> Pin<&'a T::Target> {
|
||||
unsafe { Pin::new_unchecked(&*Pin::into_inner_unchecked(this).inner.deref::<T>()) }
|
||||
}
|
||||
}
|
||||
|
||||
/// `VRefMut<'a MyTraitVTable>` can be thought as a `&'a mut dyn MyTrait`
|
||||
|
@ -376,15 +371,6 @@ impl<'a, T: ?Sized + VTableMeta> VRefMut<'a, T> {
|
|||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Return a Pin reference to the target, with the same lifetime
|
||||
pub fn as_pin_ref(this: Pin<Self>) -> Pin<&'a mut T::Target> {
|
||||
unsafe {
|
||||
Pin::new_unchecked(
|
||||
&mut *(Pin::into_inner_unchecked(this).inner.deref::<T>() as *mut T::Target),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Creates a `VRef` or a `VRefMut` suitable for an instance that implements the trait
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue