Skip to content

fix: wrap NSView::new in unsafe block for objc2 compatibility#27

Merged
freethinkel merged 1 commit intofreethinkel:mainfrom
welchjp:fix/nsview-unsafe-block
Feb 6, 2026
Merged

fix: wrap NSView::new in unsafe block for objc2 compatibility#27
freethinkel merged 1 commit intofreethinkel:mainfrom
welchjp:fix/nsview-unsafe-block

Conversation

@welchjp
Copy link
Copy Markdown
Contributor

@welchjp welchjp commented Feb 5, 2026

Summary

NSView::new was made unsafe in objc2-app-kit 0.3.x as part of objc2's ongoing safety audit. This causes compilation errors when building with current dependency versions:

error[E0133]: call to unsafe function `NSView::new` is unsafe and requires unsafe function or block
  --> src/popover.rs:30:27
   |
30 |         let placeholder = NSView::new(mtm);
   |                           ^^^^^^^^^^^^^^^^ call to unsafe function

Fix

Wrapped the NSView::new call in an unsafe block with a safety comment. The call is safe because we have a valid MainThreadMarker, which guarantees we're on the main thread as required by AppKit.

Testing

  • Tested with cargo check - compiles successfully
  • Tested in a Tauri 2.x application - popover displays and functions correctly

NSView::new was made unsafe in objc2-app-kit 0.3.x (following objc2's
safety audit). This causes compilation errors with current Cargo.lock
versions:

  error[E0133]: call to unsafe function `NSView::new` is unsafe and
  requires unsafe function or block

The call is safe because we have a valid MainThreadMarker, which
guarantees we're on the main thread as required by AppKit.
@freethinkel
Copy link
Copy Markdown
Owner

Thank you for the PR! LGTM

@freethinkel freethinkel merged commit 67c5315 into freethinkel:main Feb 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants