mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2024-12-23 19:31:30 +11:00
Fix: winuser | DestroyWindow (#230)
* winuser | DestroyWindow * rustfmt pass
This commit is contained in:
parent
c1ff776260
commit
ffa4a55487
30
examples/drop.rs
Normal file
30
examples/drop.rs
Normal file
|
@ -0,0 +1,30 @@
|
|||
use minifb::{Key, ScaleMode, Window, WindowOptions};
|
||||
use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
const WIDTH: usize = 640 / 2;
|
||||
const HEIGHT: usize = 360 / 2;
|
||||
|
||||
fn show_window() {
|
||||
let mut window = Window::new(
|
||||
"Drop Test - Window will close after 2 seconds.",
|
||||
WIDTH,
|
||||
HEIGHT,
|
||||
WindowOptions::default(),
|
||||
)
|
||||
.expect("Unable to create window");
|
||||
|
||||
let now = Instant::now();
|
||||
|
||||
while window.is_open() && now.elapsed().as_secs() < 2 {
|
||||
window.update();
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("Showing Window");
|
||||
show_window();
|
||||
println!("Dropped");
|
||||
thread::sleep(Duration::from_millis(2000));
|
||||
println!("Exiting");
|
||||
}
|
|
@ -1272,7 +1272,7 @@ impl Drop for Window {
|
|||
}
|
||||
|
||||
if self.window.is_some() {
|
||||
winuser::CloseWindow(self.window.unwrap());
|
||||
winuser::DestroyWindow(self.window.unwrap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue