1
0
Fork 0

don't need to reset userdata, just leak the Arc with into_raw so it stays alive

This commit is contained in:
Micah Johnston 2020-09-05 20:40:39 -05:00
parent 6e7038d26e
commit 9d39ba9117
2 changed files with 3 additions and 7 deletions

View file

@ -35,9 +35,7 @@ pub(crate) unsafe fn handle_message<A: AppWindow>(
handle_timer(win, wparam); handle_timer(win, wparam);
0 0
} }
WM_PAINT => { WM_PAINT => 0,
0
}
_ => DefWindowProcA(hwnd, message, wparam, lparam), _ => DefWindowProcA(hwnd, message, wparam, lparam),
} }
} }

View file

@ -68,10 +68,8 @@ unsafe extern "system" fn wnd_proc<A: AppWindow>(
// todo: need_reconfigure thing? // todo: need_reconfigure thing?
// Needed otherwise it crashes because it drops the userdata // If we don't do this, the Arc will be dropped and we'll get a crash.
// We basically need to keep the GWLP_USERDATA fresh between calls of the proc let _ = Arc::into_raw(win_ref);
// DO NOT REMOVE
SetWindowLongPtrA(hwnd, GWLP_USERDATA, Arc::into_raw(win_ref) as *const _ as _);
return ret; return ret;
} }