1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-29 04:40:03 -04:00

eframe: Use objc2 and its framework crates (#4395)

These are a replacement to the `objc` and `cocoa` crates.

This PR prevents:
- An extra copy when creating `NSData`
- A memory leak when creating `NSImage`
- A memory leak when creating `NSString`

And is generally a readability improvement.

Note that we define `NSApp` manually for now, the implementation in
`objc2-app-kit` is currently suboptimal and wouldn't allow you to check
whether the NSApplication has been created or not.

Related: https://github.com/emilk/egui/issues/4219, this should nicely
coincide with the Winit `0.30` release.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
Mads Marquart
2024-04-23 17:35:12 +02:00
committed by GitHub
parent 2c590636b5
commit 14194f5d3a
4 changed files with 99 additions and 63 deletions

View File

@@ -178,8 +178,19 @@ wgpu = { workspace = true, optional = true, features = [
# mac:
[target.'cfg(any(target_os = "macos"))'.dependencies]
cocoa = "0.25.0"
objc = "0.2.7"
objc2 = "0.5.1"
objc2-foundation = { version = "0.2.0", features = [
"block2",
"NSData",
"NSString",
] }
objc2-app-kit = { version = "0.2.0", features = [
"NSApplication",
"NSImage",
"NSMenu",
"NSMenuItem",
"NSResponder",
] }
# windows:
[target.'cfg(any(target_os = "windows"))'.dependencies]