Skip to content

Commit ed97533

Browse files
Actually clear hook wrapper (whoops)
1 parent 4be2fec commit ed97533

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/win/hook.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,13 @@ fn deinit_keyboard_hook(hwnd: HWNDWrapper) {
8686
windows.remove(&hwnd);
8787

8888
if windows.is_empty() {
89-
if let Ok(Some(hook)) = HOOK.lock().as_deref() {
90-
unsafe {
91-
UnhookWindowsHookEx(hook.0);
89+
if let Ok(mut hook) = HOOK.lock() {
90+
if let Some(KeyboardHook(hhook)) = &mut *hook {
91+
unsafe {
92+
UnhookWindowsHookEx(*hhook);
93+
}
94+
95+
*hook = None;
9296
}
9397
}
9498
}
@@ -128,7 +132,9 @@ unsafe fn offer_message_to_baseview(msg: *mut MSG) -> bool {
128132
}
129133

130134
// check if this is one of our windows. if so, intercept it
131-
if OPEN_WINDOWS.read().unwrap().contains(&HWNDWrapper(msg.hwnd)) {
135+
let Ok(windows) = OPEN_WINDOWS.read() else { return false };
136+
137+
if windows.contains(&HWNDWrapper(msg.hwnd)) {
132138
let _ = wnd_proc(msg.hwnd, msg.message, msg.wParam, msg.lParam);
133139

134140
return true;

0 commit comments

Comments
 (0)