diff --git a/src/win/window.rs b/src/win/window.rs index 7d3ccbe..40f50e6 100644 --- a/src/win/window.rs +++ b/src/win/window.rs @@ -45,7 +45,7 @@ unsafe fn generate_guid() -> String { const WIN_FRAME_TIMER: usize = 4242; -unsafe fn handle_timer(win: &Arc>>, timer_id: usize) { +unsafe fn handle_timer(win: &Mutex>, timer_id: usize) { match timer_id { WIN_FRAME_TIMER => {} _ => (), @@ -65,7 +65,7 @@ unsafe extern "system" fn wnd_proc( let win_ptr = GetWindowLongPtrA(hwnd, GWLP_USERDATA) as *const c_void; if !win_ptr.is_null() { - let win: Arc>> = Arc::from_raw(win_ptr as *mut Mutex>); + let win: &Mutex> = &*(win_ptr as *const Mutex>); match msg { WM_MOUSEMOVE => { @@ -83,9 +83,6 @@ unsafe extern "system" fn wnd_proc( } _ => {} } - - // If we don't do this, the Arc will be dropped and we'll get a crash. - let _ = Arc::into_raw(win); } return DefWindowProcA(hwnd, msg, wparam, lparam);