Skip to content

Commit

Permalink
Fix some deadlocks that could occur when changing window state
Browse files Browse the repository at this point in the history
  • Loading branch information
Osspial committed Nov 16, 2018
1 parent 2a3cefd commit 5a3a5e2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/platform_impl/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ impl Window {
if currently_grabbed == grab && grab == window_state_lock.cursor_grabbed {
return Ok(());
}
drop(window_state_lock);
let window = self.window.clone();
let window_state = Arc::clone(&self.window_state);
let (tx, rx) = channel();
Expand All @@ -435,7 +436,6 @@ impl Window {
}
let _ = tx.send(result);
});
drop(window_state_lock);
rx.recv().unwrap()
}

Expand Down Expand Up @@ -500,6 +500,7 @@ impl Window {
// We only maximize if we're not in fullscreen.
if window_state.fullscreen.is_none() {
let window = self.window.clone();
drop(window_state);
unsafe {
// `ShowWindow` resizes the window, so it must be called from the main thread.
self.thread_executor.execute_in_thread(move || {
Expand Down Expand Up @@ -754,6 +755,7 @@ impl Window {
let mut window_state = self.window_state.lock();
if mem::replace(&mut window_state.always_on_top, always_on_top) != always_on_top {
let window = self.window.clone();
drop(window_state);
self.thread_executor.execute_in_thread(move || {
let insert_after = if always_on_top {
winuser::HWND_TOPMOST
Expand Down

0 comments on commit 5a3a5e2

Please sign in to comment.