Retain ApplicationDelegate in NSWindowDelegate and NSView

The delegate is only weakly referenced by NSApplication, so getting it
from there may fail if the event loop has been dropped.

Fixes #3668.
This commit is contained in:
Mads Marquart 2024-05-06 16:29:07 +02:00 committed by GitHub
parent 16fd2baba0
commit 0a3cacd577
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 55 additions and 23 deletions

View file

@ -78,6 +78,10 @@ impl ActiveEventLoop {
RootWindowTarget { p, _marker: PhantomData }
}
pub(super) fn app_delegate(&self) -> &ApplicationDelegate {
&self.delegate
}
pub fn create_custom_cursor(&self, source: CustomCursorSource) -> RootCustomCursor {
RootCustomCursor { inner: CustomCursor::new(source.inner) }
}
@ -133,9 +137,7 @@ impl ActiveEventLoop {
pub(crate) fn owned_display_handle(&self) -> OwnedDisplayHandle {
OwnedDisplayHandle
}
}
impl ActiveEventLoop {
pub(crate) fn hide_application(&self) {
NSApplication::sharedApplication(self.mtm).hide(None)
}