Skip to content

Commit 4c6631c

Browse files
committed
mac: retain the NSWindow to ensure that the call to retrieving the backing scale factor in set_buffer works
1 parent 2832a6e commit 4c6631c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/cg.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ pub struct CGImpl {
2222
impl CGImpl {
2323
pub unsafe fn new(handle: AppKitWindowHandle) -> Result<Self, SoftBufferError> {
2424
let window = handle.ns_window as id;
25+
let window: id = msg_send![window, retain];
2526
let view = handle.ns_view as id;
2627
let layer = CALayer::new();
2728
unsafe {
@@ -71,3 +72,11 @@ impl CGImpl {
7172
transaction::commit();
7273
}
7374
}
75+
76+
impl Drop for CGImpl {
77+
fn drop(&mut self) {
78+
unsafe {
79+
let _: () = msg_send![self.window, release];
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)