macOS: Fix double-free of NSWindow

This commit is contained in:
Mads Marquart 2023-11-15 02:15:33 +01:00
parent 800f640270
commit f198b222bd
2 changed files with 6 additions and 1 deletions

View file

@ -1,3 +1,7 @@
# Unreleased
- MacOS: Fix double-free of `NSWindow`.
# 0.4.0
- **Breaking:** Port to use `raw-window-handle` v0.6.(#132)

View file

@ -42,7 +42,8 @@ impl<D: HasDisplayHandle, W: HasWindowHandle> CGImpl<D, W> {
_ => return Err(InitError::Unsupported(window_src)),
};
let view = handle.ns_view.as_ptr() as id;
let window = unsafe { msg_send![view, window] };
let window: id = unsafe { msg_send![view, window] };
let window: id = unsafe { msg_send![window, retain] };
let layer = CALayer::new();
unsafe {
let subview: id = NSView::alloc(nil).initWithFrame_(NSView::frame(view));