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:
parent
16fd2baba0
commit
0a3cacd577
6 changed files with 55 additions and 23 deletions
|
|
@ -28,7 +28,9 @@ impl Window {
|
|||
attributes: WindowAttributes,
|
||||
) -> Result<Self, RootOsError> {
|
||||
let mtm = window_target.mtm;
|
||||
let delegate = autoreleasepool(|_| WindowDelegate::new(attributes, mtm))?;
|
||||
let delegate = autoreleasepool(|_| {
|
||||
WindowDelegate::new(window_target.app_delegate(), attributes, mtm)
|
||||
})?;
|
||||
Ok(Window {
|
||||
window: MainThreadBound::new(delegate.window().retain(), mtm),
|
||||
delegate: MainThreadBound::new(delegate, mtm),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue