On macOS, fix WindowEvent::Destroyed isn't emitted #2544
Conversation
madsmtm
left a comment
There was a problem hiding this comment.
Huh, odd that this hasn't been discovered before! Does this mean that our overriding of windowWillClose: is effectively useless?
However, I doubt this fixes the problem completely, since the window may be closed before the last reference to it is destroyed (for example in the window_debug example). Do you have an idea for how to fix this?
| let event = Event::WindowEvent { | ||
| window_id: WindowId(window.id()), | ||
| event: WindowEvent::Destroyed, | ||
| }; | ||
| AppState::queue_event(EventWrapper::StaticEvent(event)); |
There was a problem hiding this comment.
Only WinitWindowDelegate has this method. Should I add such method to WinitWindow too? Or could I just access WinitWindowDelegate by pub(crate) it.
There was a problem hiding this comment.
I found the delegate has to be used in exec_async somehow, so windowWillCose can be invoked.
So I call delegate.window.close() instead which should look a little bit cleaner.
I couldn't find any other way to trigger
Yeah, |
Then we should maybe remove the code in it, along with a note? Though I'm a bit weary about doing so, since it seems like, see this commit from 2018 that added the note about El Capitan goddessfreya@8e9fc01 (from PR #853). @francesca64 do you remember anything about this?
Would you mind documenting this on |
|
@madsmtm I sadly don't remember, sorry! |
|
No worries, thanks for the quick response! |
|
Cool, I went and merged that so will close this now. Thanks for your help! |
It seems
windowWillClosecan only be called whenwindowShouldClosereturns true.So the
WindowEvent::Destroyedis never called when the window is dropped.This PR add another queue event when the window is dropped during Drop trait is called.
CHANGELOG.mdif knowledge of this change could be valuable to users