Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retain calayer after creation #546

Merged
merged 3 commits into from
Aug 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion cocoa/src/quartzcore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ impl CALayer {

#[inline]
pub fn new() -> CALayer {
unsafe { CALayer(msg_send![class!(CALayer), layer]) }
unsafe {
let id: id = msg_send![class!(CALayer), layer];
let _: id = msg_send![id, retain];
CALayer(id)
xiaopengli89 marked this conversation as resolved.
Show resolved Hide resolved
}
}

#[inline]
Expand Down Expand Up @@ -1674,3 +1678,15 @@ pub type CVSMPTETimeFlags = u32;

pub const kCVSMPTETimeValid: CVSMPTETimeFlags = 1 << 0;
pub const kCVSMPTETimeRunning: CVSMPTETimeFlags = 1 << 1;

#[cfg(test)]
mod test {
use super::CALayer;

#[test]
fn create_calayer() {
objc::rc::autoreleasepool(|| {
let _ = CALayer::new();
});
}
}