Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(macos): fall back to existing CapWindowDelegate class if registration races

ManthanNimodiya315dfe8495e6
diff --git a/apps/desktop/src-tauri/src/platform/macos/delegates.rs b/apps/desktop/src-tauri/src/platform/macos/delegates.rs
index d050bde8a..65db4237f 100644
--- a/apps/desktop/src-tauri/src/platform/macos/delegates.rs
+++ b/apps/desktop/src-tauri/src/platform/macos/delegates.rs
@@ -373,8 +373,13 @@ pub fn setup<R: Runtime>(window: Window<R>, controls_inset: LogicalPosition<f64>
return existing;
}
- let mut decl = ClassDecl::new("CapWindowDelegate", class!(NSObject))
- .expect("failed to register CapWindowDelegate");
+ let mut decl = match ClassDecl::new("CapWindowDelegate", class!(NSObject)) {
+ Some(decl) => decl,
+ None => {
+ return Class::get("CapWindowDelegate")
+ .expect("CapWindowDelegate should exist if already registered");
+ }
+ };
decl.add_ivar::<id>("window");
decl.add_ivar::<*mut c_void>("app_box");