don't need to reset userdata, just leak the Arc with into_raw so it stays alive
This commit is contained in:
parent
6e7038d26e
commit
9d39ba9117
|
@ -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),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue