windows: Update windows-rs crate and better error handling in DirectWrite (#12818)

- Update `windows-rs` from `0.56` to `0.57`
- Use the newly introduced `Owned` struct in `0.57` to handle the RAII
stuff of `HANDLE`
- Better error handling in `DirectWrite`

Release Notes:

- N/A
This commit is contained in:
张小白 2024-06-15 01:12:20 +08:00 committed by GitHub
parent 1413b5af93
commit 4cb45e63f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 116 additions and 167 deletions

View file

@ -162,16 +162,11 @@ impl Platform for WindowsPlatform {
fn run(&self, on_finish_launching: Box<dyn 'static + FnOnce()>) {
on_finish_launching();
let vsync_event = create_event().unwrap();
begin_vsync(vsync_event.to_raw());
let vsync_event = unsafe { Owned::new(CreateEventW(None, false, false, None).unwrap()) };
begin_vsync(*vsync_event);
'a: loop {
let wait_result = unsafe {
MsgWaitForMultipleObjects(
Some(&[vsync_event.to_raw()]),
false,
INFINITE,
QS_ALLINPUT,
)
MsgWaitForMultipleObjects(Some(&[*vsync_event]), false, INFINITE, QS_ALLINPUT)
};
match wait_result {