windows: Remove SmartGlobal (#30366)

Closes #29657

Using `with_clipboard_data()` to ensure that `GlobalLock` and
`GlobalUnlock` are called correctly.

Release Notes:

- N/A
This commit is contained in:
张小白 2025-05-09 20:05:53 +08:00 committed by GitHub
parent 30f3efe697
commit 89ce49d5b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 58 additions and 74 deletions

View file

@ -1,11 +1,6 @@
use std::ops::Deref;
use util::ResultExt;
use windows::Win32::{
Foundation::{HANDLE, HGLOBAL},
System::Memory::{GlobalLock, GlobalSize, GlobalUnlock},
UI::WindowsAndMessaging::HCURSOR,
};
use windows::Win32::{Foundation::HANDLE, UI::WindowsAndMessaging::HCURSOR};
#[derive(Debug, Clone, Copy)]
pub(crate) struct SafeHandle {
@ -50,30 +45,3 @@ impl Deref for SafeCursor {
&self.raw
}
}
#[derive(Debug, Clone)]
pub(crate) struct SmartGlobal {
raw: HGLOBAL,
}
impl SmartGlobal {
pub(crate) fn from_raw_ptr(ptr: *mut std::ffi::c_void) -> Self {
Self { raw: HGLOBAL(ptr) }
}
pub(crate) fn lock(&self) -> *mut std::ffi::c_void {
unsafe { GlobalLock(self.raw) }
}
pub(crate) fn size(&self) -> usize {
unsafe { GlobalSize(self.raw) }
}
}
impl Drop for SmartGlobal {
fn drop(&mut self) {
unsafe {
GlobalUnlock(self.raw).log_err();
}
}
}