Fix crash when minimizing example on Windows
This commit is contained in:
parent
52af1b4a77
commit
d333dd8664
1 changed files with 8 additions and 5 deletions
|
|
@ -53,6 +53,13 @@ pub(super) fn fill_window(window: &Window) {
|
||||||
}
|
}
|
||||||
|
|
||||||
GC.with(|gc| {
|
GC.with(|gc| {
|
||||||
|
let size = window.inner_size();
|
||||||
|
let (Some(width), Some(height)) =
|
||||||
|
(NonZeroU32::new(size.width), NonZeroU32::new(size.height))
|
||||||
|
else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
// Either get the last context used or create a new one.
|
// Either get the last context used or create a new one.
|
||||||
let mut gc = gc.borrow_mut();
|
let mut gc = gc.borrow_mut();
|
||||||
let surface = gc
|
let surface = gc
|
||||||
|
|
@ -61,13 +68,9 @@ pub(super) fn fill_window(window: &Window) {
|
||||||
|
|
||||||
// Fill a buffer with a solid color.
|
// Fill a buffer with a solid color.
|
||||||
const DARK_GRAY: u32 = 0xFF181818;
|
const DARK_GRAY: u32 = 0xFF181818;
|
||||||
let size = window.inner_size();
|
|
||||||
|
|
||||||
surface
|
surface
|
||||||
.resize(
|
.resize(width, height)
|
||||||
NonZeroU32::new(size.width).expect("Width must be greater than zero"),
|
|
||||||
NonZeroU32::new(size.height).expect("Height must be greater than zero"),
|
|
||||||
)
|
|
||||||
.expect("Failed to resize the softbuffer surface");
|
.expect("Failed to resize the softbuffer surface");
|
||||||
|
|
||||||
let mut buffer = surface
|
let mut buffer = surface
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue