mirror of
https://github.com/slint-ui/slint.git
synced 2025-10-02 06:41:14 +00:00
Make sixtyfps::Weak<T>::upgrade_in_event_loop
easier to use
... by taking &self instead of self cc #431
This commit is contained in:
parent
9e03d9b718
commit
a79f3c7185
1 changed files with 3 additions and 2 deletions
|
@ -653,12 +653,13 @@ mod weak_handle {
|
|||
/// handle.run();
|
||||
/// ```
|
||||
#[cfg(feature = "std")]
|
||||
pub fn upgrade_in_event_loop(self, func: impl FnOnce(T) + Send + 'static)
|
||||
pub fn upgrade_in_event_loop(&self, func: impl FnOnce(T) + Send + 'static)
|
||||
where
|
||||
T: 'static,
|
||||
{
|
||||
let weak_handle = self.clone();
|
||||
crate::invoke_from_event_loop(move || {
|
||||
if let Some(h) = self.upgrade() {
|
||||
if let Some(h) = weak_handle.upgrade() {
|
||||
func(h);
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue