Web: async improvements (#3805)
- Internal: Fix dropping `Notifier` without sending a result causing `Future`s to never complete. This should never happen anyway, but now we get a panic instead of nothing if we hit a bug. - Internal: Remove a bunch of `unwrap()`s that aren't required when correctly using `MainThreadMarker`. - `Window::canvas()` is now able to return a reference instead of an owned value. Extracted from #3801.
This commit is contained in:
parent
5ec934b1b0
commit
ef580b817d
12 changed files with 238 additions and 219 deletions
|
|
@ -178,7 +178,7 @@ impl Future for CustomCursorFuture {
|
|||
panic!("`CustomCursorFuture` polled after completion")
|
||||
}
|
||||
|
||||
let result = ready!(Pin::new(&mut self.notified).poll(cx));
|
||||
let result = ready!(Pin::new(&mut self.notified).poll(cx)).unwrap();
|
||||
let state = self.state.take().expect("`CustomCursorFuture` polled after completion");
|
||||
|
||||
Poll::Ready(result.map(|_| CustomCursor { animation: self.animation, state }))
|
||||
|
|
@ -662,7 +662,7 @@ async fn from_animation(
|
|||
ImageState::Loading { notifier, .. } => {
|
||||
let notified = notifier.notified();
|
||||
drop(state);
|
||||
notified.await?;
|
||||
notified.await.unwrap()?;
|
||||
},
|
||||
ImageState::Failed(error) => return Err(error.clone()),
|
||||
ImageState::Image(_) => drop(state),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue