Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

gpui: Fix Core Foundation object leaks on macOS (#49022)

Albab Hasandf905d3893fe
diff --git a/crates/gpui_macos/src/display.rs b/crates/gpui_macos/src/display.rs
index 20ffa6fa2fc..b9338bff846 100644
--- a/crates/gpui_macos/src/display.rs
+++ b/crates/gpui_macos/src/display.rs
@@ -5,6 +5,7 @@ use cocoa::{
base::{id, nil},
foundation::{NSArray, NSDictionary},
};
+use core_foundation::base::CFRelease;
use core_foundation::uuid::{CFUUIDGetUUIDBytes, CFUUIDRef};
use core_graphics::display::{CGDirectDisplayID, CGDisplayBounds, CGGetActiveDisplayList};
use gpui::{Bounds, DisplayId, Pixels, PlatformDisplay, point, px, size};
@@ -83,6 +84,7 @@ impl PlatformDisplay for MacDisplay {
);
let bytes = unsafe { CFUUIDGetUUIDBytes(cfuuid) };
+ unsafe { CFRelease(cfuuid as _) };
Ok(Uuid::from_bytes([
bytes.byte0,
bytes.byte1,
diff --git a/crates/gpui_macos/src/keyboard.rs b/crates/gpui_macos/src/keyboard.rs
index 68c497f0679..63e56a260a2 100644
--- a/crates/gpui_macos/src/keyboard.rs
+++ b/crates/gpui_macos/src/keyboard.rs
@@ -69,6 +69,8 @@ impl MacKeyboardLayout {
let name: *const std::os::raw::c_char = msg_send![name, UTF8String];
let name = CStr::from_ptr(name).to_str().unwrap().to_string();
+ let _: () = msg_send![current_keyboard, release];
+
Self { id, name }
}
}