Skip to content

Commit f65c764

Browse files
fixed parented_window crash
1 parent 237d323 commit f65c764

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/macos/window.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,22 @@ impl<'a> Window<'a> {
149149
panic!("Not a macOS window");
150150
};
151151

152+
let parent_window = if !handle.ns_window.is_null() {
153+
handle.ns_window as *mut Object
154+
} else {
155+
let parent_view = handle.ns_view as id;
156+
unsafe {
157+
let window: id = msg_send![parent_view, window];
158+
window as *mut Object
159+
}
160+
};
161+
152162
let ns_view = unsafe { create_view(&options) };
153163

154164
let window_inner = WindowInner {
155165
open: Cell::new(true),
156166
ns_app: Cell::new(None),
157-
ns_window: Cell::new(None),
167+
ns_window: Cell::new(Some(parent_window)),
158168
ns_view,
159169

160170
#[cfg(feature = "opengl")]

0 commit comments

Comments
 (0)