Skip to content

Commit

Permalink
Fix windows lifetimes
Browse files Browse the repository at this point in the history
Co-Authored-By: TornaxO7 <tornax@proton.me>
Signed-off-by: John Nunley <dev@notgull.net>
  • Loading branch information
notgull and TornaxO7 committed Oct 14, 2023
1 parent 9a861b6 commit 2933b0a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/platform_impl/windows/event_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,8 +982,7 @@ pub(super) unsafe extern "system" fn public_window_callback<T: 'static>(
let userdata_ptr = match (userdata, msg) {
(0, WM_NCCREATE) => {
let createstruct = unsafe { &mut *(lparam as *mut CREATESTRUCTW) };
let initdata =
unsafe { &mut *(createstruct.lpCreateParams as *mut InitData<'_, '_, T>) };
let initdata = unsafe { &mut *(createstruct.lpCreateParams as *mut InitData<'_, T>) };

let result = match unsafe { initdata.on_nccreate(window) } {
Some(userdata) => unsafe {
Expand All @@ -1001,7 +1000,7 @@ pub(super) unsafe extern "system" fn public_window_callback<T: 'static>(
(_, WM_CREATE) => unsafe {
let createstruct = &mut *(lparam as *mut CREATESTRUCTW);
let initdata = createstruct.lpCreateParams;
let initdata = &mut *(initdata as *mut InitData<'_, '_, T>);
let initdata = &mut *(initdata as *mut InitData<'_, T>);

initdata.on_create();
return DefWindowProcW(window, msg, wparam, lparam);
Expand Down
6 changes: 3 additions & 3 deletions src/platform_impl/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1028,17 +1028,17 @@ pub struct WindowWrapper(HWND);
unsafe impl Sync for WindowWrapper {}
unsafe impl Send for WindowWrapper {}

pub(super) struct InitData<'a, 'b, T: 'static> {
pub(super) struct InitData<'a, T: 'static> {
// inputs
pub event_loop: &'a EventLoopWindowTarget<T>,
pub attributes: WindowAttributes<'b>,
pub attributes: WindowAttributes,
pub pl_attribs: PlatformSpecificWindowBuilderAttributes,
pub window_flags: WindowFlags,
// outputs
pub window: Option<Window>,
}

impl<'a, T: 'static> InitData<'a, '_, T> {
impl<'a, T: 'static> InitData<'a, T> {
unsafe fn create_window(&self, window: HWND) -> Window {
// Register for touch events if applicable
{
Expand Down

0 comments on commit 2933b0a

Please sign in to comment.