Retain calayer after creation (#546)

* Retain calayer after creation

* Fix fmt

* fix create_calayer test
This commit is contained in:
Xiaopeng Li
2024-08-10 00:48:56 +08:00
committed by GitHub
parent 652bab0a62
commit b10f1efc48
+17 -1
View File
@@ -65,7 +65,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)
}
}
#[inline]
@@ -1680,3 +1684,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();
});
}
}