Skip to content

Commit

Permalink
Windows: Fix panic when calling set_fullscreen(None) (#502)
Browse files Browse the repository at this point in the history
* Windows: Fix panic for set_fullscreen(None) (#501)

* Add condition to prevent panic

Trying to call set_fullscreen(None) on a window that has never been in
fullscreen mode caused a panic before this change.
The responsible method now simply checks if this precondition is met and
returns (does nothing) otherwise.

* Add entry to CHANGELOG

* Add platform specification to CHANGELOG entry

Forgot to add that the to_fullscreen(None) bugfix is Windows only in
CHANGELOG.
  • Loading branch information
Jack Magnus authored and francesca64 committed May 8, 2018
1 parent 102dd07 commit 3632610
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Rework of the wayland backend, migrating it to use [Smithay's Client Toolkit](https://github.com/Smithay/client-toolkit).
- Added `WindowBuilder::with_window_icon` and `Window::set_window_icon`, finally making it possible to set the window icon on Windows and X11. The `icon_loading` feature can be enabled to allow for icons to be easily loaded; see example program `window_icon.rs` for usage.
- Windows additionally has `WindowBuilderExt::with_taskbar_icon` and `WindowExt::set_taskbar_icon`.
- On Windows, fix panic when trying to call `set_fullscreen(None)` on a window that has not been fullscreened prior.

# Version 0.13.1 (2018-04-26)

Expand Down
7 changes: 7 additions & 0 deletions src/platform/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,13 @@ impl Window {

unsafe fn restore_saved_window(&self) {
let window_state = self.window_state.lock().unwrap();

// 'saved_window_info' can be None if the window has never been
// in fullscreen mode before this method gets called.
if window_state.saved_window_info.is_none() {
return;
}

// Reset original window style and size. The multiple window size/moves
// here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be
// repainted. Better-looking methods welcome.
Expand Down

0 comments on commit 3632610

Please sign in to comment.