mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2025-01-09 21:01:29 +11:00
Fix device description leak (#2758)
* Fix device description leak * Update CHANGELOG.md --------- Co-authored-by: Xiaopeng Li <lixiaopeng.jetspark@bytedance.com>
This commit is contained in:
parent
25c4e2e451
commit
92592ec605
|
@ -24,6 +24,7 @@ And please only add new entries to the top of this list, right below the `# Unre
|
|||
- On macOS, fix empty marked text blocking regular input.
|
||||
- On macOS, fix potential panic when getting refresh rate.
|
||||
- On macOS, fix crash when calling `Window::set_ime_position` from another thread.
|
||||
- On macOS, fixed memory leak when getting monitor handle.
|
||||
|
||||
# 0.28.3
|
||||
|
||||
|
|
|
@ -39,21 +39,25 @@ extern_methods!(
|
|||
}
|
||||
|
||||
pub fn display_id(&self) -> u32 {
|
||||
let device_description = self.deviceDescription();
|
||||
let key = ns_string!("NSScreenNumber");
|
||||
|
||||
// Retrieve the CGDirectDisplayID associated with this screen
|
||||
//
|
||||
// SAFETY: The value from @"NSScreenNumber" in deviceDescription is guaranteed
|
||||
// to be an NSNumber. See documentation for `deviceDescription` for details:
|
||||
// <https://developer.apple.com/documentation/appkit/nsscreen/1388360-devicedescription?language=objc>
|
||||
let obj = device_description
|
||||
.get(ns_string!("NSScreenNumber"))
|
||||
.expect("failed getting screen display id from device description");
|
||||
let obj: *const Object = obj;
|
||||
let obj: *const NSNumber = obj.cast();
|
||||
let obj: &NSNumber = unsafe { &*obj };
|
||||
objc2::rc::autoreleasepool(|_| {
|
||||
let device_description = self.deviceDescription();
|
||||
|
||||
obj.as_u32()
|
||||
// Retrieve the CGDirectDisplayID associated with this screen
|
||||
//
|
||||
// SAFETY: The value from @"NSScreenNumber" in deviceDescription is guaranteed
|
||||
// to be an NSNumber. See documentation for `deviceDescription` for details:
|
||||
// <https://developer.apple.com/documentation/appkit/nsscreen/1388360-devicedescription?language=objc>
|
||||
let obj = device_description
|
||||
.get(key)
|
||||
.expect("failed getting screen display id from device description");
|
||||
let obj: *const Object = obj;
|
||||
let obj: *const NSNumber = obj.cast();
|
||||
let obj: &NSNumber = unsafe { &*obj };
|
||||
|
||||
obj.as_u32()
|
||||
})
|
||||
}
|
||||
|
||||
#[sel(backingScaleFactor)]
|
||||
|
|
Loading…
Reference in a new issue