Windows: Fix panic when calling set_fullscreen(None) (#502)

* 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.
This commit is contained in:
Jack Magnus 2018-05-08 14:16:49 +02:00 committed by Francesca Frangipane
parent 102dd07456
commit 363261077f
2 changed files with 8 additions and 0 deletions

View file

@ -18,6 +18,7 @@
- Rework of the wayland backend, migrating it to use [Smithay's Client Toolkit](https://github.com/Smithay/client-toolkit). - 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. - 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`. - 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) # Version 0.13.1 (2018-04-26)

View file

@ -425,6 +425,13 @@ impl Window {
unsafe fn restore_saved_window(&self) { unsafe fn restore_saved_window(&self) {
let window_state = self.window_state.lock().unwrap(); 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 // 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 // here are ugly, but if SetWindowPos() doesn't redraw, the taskbar won't be
// repainted. Better-looking methods welcome. // repainted. Better-looking methods welcome.