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.

Retain run loop (#11241)

Conrad Irwin6b55a6f0e1de
diff --git a/Cargo.lock b/Cargo.lock
index 3620ea1aac5..a28fea414f0 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4105,6 +4105,7 @@ name = "fsevent"
version = "0.1.0"
dependencies = [
"bitflags 2.4.2",
+ "core-foundation",
"fsevent-sys 3.1.0",
"parking_lot",
"tempfile",
diff --git a/crates/fsevent/Cargo.toml b/crates/fsevent/Cargo.toml
index 6a5a01843d1..957917bf92e 100644
--- a/crates/fsevent/Cargo.toml
+++ b/crates/fsevent/Cargo.toml
@@ -17,6 +17,7 @@ bitflags.workspace = true
parking_lot.workspace = true
[target.'cfg(target_os = "macos")'.dependencies]
+core-foundation.workspace = true
fsevent-sys = "3.0.2"
[dev-dependencies]
diff --git a/crates/fsevent/src/fsevent.rs b/crates/fsevent/src/fsevent.rs
index ef113b6de2a..533bb909798 100644
--- a/crates/fsevent/src/fsevent.rs
+++ b/crates/fsevent/src/fsevent.rs
@@ -120,7 +120,8 @@ impl EventStream {
{
self.state.callback = Some(Box::new(f));
unsafe {
- let run_loop = cf::CFRunLoopGetCurrent();
+ let run_loop =
+ core_foundation::base::CFRetain(cf::CFRunLoopGetCurrent()) as *mut c_void;
{
let mut state = self.lifecycle.lock();
match *state {
@@ -248,6 +249,7 @@ impl Drop for Handle {
if let Lifecycle::Running(run_loop) = *state {
unsafe {
cf::CFRunLoopStop(run_loop);
+ cf::CFRelease(run_loop)
}
}
*state = Lifecycle::Stopped;