Skip to content

Commit 5a3a5e2

Browse files
committed
Fix some deadlocks that could occur when changing window state
1 parent 2a3cefd commit 5a3a5e2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/platform_impl/windows/window.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ impl Window {
425425
if currently_grabbed == grab && grab == window_state_lock.cursor_grabbed {
426426
return Ok(());
427427
}
428+
drop(window_state_lock);
428429
let window = self.window.clone();
429430
let window_state = Arc::clone(&self.window_state);
430431
let (tx, rx) = channel();
@@ -435,7 +436,6 @@ impl Window {
435436
}
436437
let _ = tx.send(result);
437438
});
438-
drop(window_state_lock);
439439
rx.recv().unwrap()
440440
}
441441

@@ -500,6 +500,7 @@ impl Window {
500500
// We only maximize if we're not in fullscreen.
501501
if window_state.fullscreen.is_none() {
502502
let window = self.window.clone();
503+
drop(window_state);
503504
unsafe {
504505
// `ShowWindow` resizes the window, so it must be called from the main thread.
505506
self.thread_executor.execute_in_thread(move || {
@@ -754,6 +755,7 @@ impl Window {
754755
let mut window_state = self.window_state.lock();
755756
if mem::replace(&mut window_state.always_on_top, always_on_top) != always_on_top {
756757
let window = self.window.clone();
758+
drop(window_state);
757759
self.thread_executor.execute_in_thread(move || {
758760
let insert_after = if always_on_top {
759761
winuser::HWND_TOPMOST

0 commit comments

Comments
 (0)