From 866ea7b35c969d43e7b60514fc5548db8b84543a Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Wed, 25 Oct 2023 08:56:19 +0200 Subject: [PATCH] cgl: relax encoding requirements for `CGLContextObj` 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. --- CHANGELOG.md | 2 ++ glutin/Cargo.toml | 3 ++- glutin/src/api/cgl/appkit.rs | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65fe527f07..253be4c9fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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`. diff --git a/glutin/Cargo.toml b/glutin/Cargo.toml index 53d3b12833..1b4ceb4d83 100644 --- a/glutin/Cargo.toml +++ b/glutin/Cargo.toml @@ -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] diff --git a/glutin/src/api/cgl/appkit.rs b/glutin/src/api/cgl/appkit.rs index ef85cae31c..325f28c99d 100644 --- a/glutin/src/api/cgl/appkit.rs +++ b/glutin/src/api/cgl/appkit.rs @@ -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!(