Skip to content

Commit

Permalink
cgl: relax encoding requirements for CGLContextObj
Browse files Browse the repository at this point in the history
The issue is that CGLContextObj changed its encoding in macOS Sonoma
14.0. The encoding of a type is something that objc2 uses to
debug-assert that the definition is written correctly, but of course, if
the Rust code assumes that the encoding is one thing, and it then
changes, then the debug assertion will now fail.

Fixes #1640.
  • Loading branch information
madsmtm authored Oct 25, 2023
1 parent 5ff4320 commit 866ea7b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Fixed `CGLContextObj` having an invalid encoding on newer macOS versions.

# Version 0.31.0

- Bump MSRV from `1.60` to `1.65`.
Expand Down
3 changes: 2 additions & 1 deletion glutin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ x11-dl = { version = "2.20.0", optional = true }
[target.'cfg(any(target_os = "macos"))'.dependencies]
cgl = "0.3.2"
core-foundation = "0.9.3"
objc2 = "0.4.1"
# Enable `relax-void-encoding` until https://github.com/madsmtm/objc2/pull/526 is resolved
objc2 = { version = "0.4.1", features = ["relax-void-encoding"] }
dispatch = "0.2.0"

[target.'cfg(any(target_os = "macos"))'.dependencies.icrate]
Expand Down
2 changes: 1 addition & 1 deletion glutin/src/api/cgl/appkit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct CGLContextObj {
}

unsafe impl RefEncode for CGLContextObj {
const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Struct("_CGLContextObject", &[]));
const ENCODING_REF: Encoding = Encoding::Pointer(&Encoding::Void);
}

extern_class!(
Expand Down

0 comments on commit 866ea7b

Please sign in to comment.