mac: retain the NSWindow to ensure that the call to retrieving the backing scale factor in set_buffer works

This commit is contained in:
Simon Hausmann 2023-01-15 17:04:57 +01:00
parent 2832a6e42b
commit 4c6631c764

View file

@ -22,6 +22,7 @@ pub struct CGImpl {
impl CGImpl {
pub unsafe fn new(handle: AppKitWindowHandle) -> Result<Self, SoftBufferError> {
let window = handle.ns_window as id;
let window: id = msg_send![window, retain];
let view = handle.ns_view as id;
let layer = CALayer::new();
unsafe {
@ -71,3 +72,11 @@ impl CGImpl {
transaction::commit();
}
}
impl Drop for CGImpl {
fn drop(&mut self) {
unsafe {
let _: () = msg_send![self.window, release];
}
}
}