Skip to content

macOS: Set ns_window to the parent window when creating WindowHandles#238

Merged
prokopyl merged 3 commits intomasterfrom
set_parent_ns_window
May 3, 2026
Merged

macOS: Set ns_window to the parent window when creating WindowHandles#238
prokopyl merged 3 commits intomasterfrom
set_parent_ns_window

Conversation

@prokopyl
Copy link
Copy Markdown
Member

@prokopyl prokopyl commented May 3, 2026

Currently, when baseview creates a window in parented mode, the WindowHandles it gives out have their ns_window field set to null, which makes some downstream libraries (such as softbuffer) crash.

This means the open_parented example completely crashes as a result, it does not even start properly on macOS.

This PR fixes this by storing the parent NSWindow pointer separately, and then using it to set the WindowHandle's ns_window field.

I can confirm it prevents the crash on macOS 26.2.

This PR supersedes the fix in #219. Unlike in that PR, this PR stores the parent NSWindow pointer separately, so it does not impact other baseview operations.

@dathinaios
Copy link
Copy Markdown
Contributor

Tested both examples and can confirm it is not crashing anymore 👍

Mac Studio M1 Max
MacOS: 15.7.3 (24G419)

@prokopyl
Copy link
Copy Markdown
Member Author

prokopyl commented May 3, 2026

@dathinaios Sweet! Thank you for taking the time to test it ^^

@prokopyl prokopyl removed the request for review from micahrj May 3, 2026 15:15
@prokopyl prokopyl merged commit ca1e687 into master May 3, 2026
6 checks passed
@prokopyl prokopyl deleted the set_parent_ns_window branch May 3, 2026 15:26
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