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:
parent
1413b5af93
commit
4cb45e63f4
6 changed files with 116 additions and 167 deletions
|
@ -1,7 +1,7 @@
|
|||
use std::sync::OnceLock;
|
||||
|
||||
use ::util::ResultExt;
|
||||
use windows::Win32::{Foundation::*, System::Threading::*, UI::WindowsAndMessaging::*};
|
||||
use windows::Win32::{Foundation::*, UI::WindowsAndMessaging::*};
|
||||
|
||||
use crate::*;
|
||||
|
||||
|
@ -74,34 +74,6 @@ pub(crate) unsafe fn set_window_long(
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct OwnedHandle(HANDLE);
|
||||
|
||||
impl OwnedHandle {
|
||||
pub(crate) fn new(handle: HANDLE) -> Self {
|
||||
Self(handle)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn to_raw(&self) -> HANDLE {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for OwnedHandle {
|
||||
fn drop(&mut self) {
|
||||
if !self.0.is_invalid() {
|
||||
unsafe { CloseHandle(self.0) }.log_err();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn create_event() -> windows::core::Result<OwnedHandle> {
|
||||
Ok(OwnedHandle::new(unsafe {
|
||||
CreateEventW(None, false, false, None)?
|
||||
}))
|
||||
}
|
||||
|
||||
pub(crate) fn windows_credentials_target_name(url: &str) -> String {
|
||||
format!("zed:url={}", url)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue