mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
fix double window class registration (#8548)
This commit is contained in:
parent
ee08b916e5
commit
43c5d27219
@ -171,6 +171,7 @@ By @SupaMaggie70Incorporated in [#8206](https://github.com/gfx-rs/wgpu/pull/8206
|
||||
#### GLES
|
||||
|
||||
- Fix race when downloading texture from compute shader pass. By @SpeedCrash100 in [#8527](https://github.com/gfx-rs/wgpu/pull/8527)
|
||||
- Fix double window class registration when dynamic libraries are used. By @Azorlogh in [#8548](https://github.com/gfx-rs/wgpu/pull/8548)
|
||||
|
||||
#### hal
|
||||
|
||||
|
||||
@ -281,6 +281,21 @@ fn create_global_window_class() -> Result<CString, crate::InstanceError> {
|
||||
let name = format!("wgpu Device Class {:x}\0", class_addr as usize);
|
||||
let name = CString::from_vec_with_nul(name.into_bytes()).unwrap();
|
||||
|
||||
// The window class may already be registered if we are a dynamic library that got
|
||||
// unloaded & loaded back into the same process. If so, just skip creation.
|
||||
let already_exists = unsafe {
|
||||
let mut wc = mem::zeroed::<WindowsAndMessaging::WNDCLASSEXA>();
|
||||
WindowsAndMessaging::GetClassInfoExA(
|
||||
Some(instance.into()),
|
||||
PCSTR(name.as_ptr().cast()),
|
||||
&mut wc,
|
||||
)
|
||||
.is_ok()
|
||||
};
|
||||
if already_exists {
|
||||
return Ok(name);
|
||||
}
|
||||
|
||||
// Use a wrapper function for compatibility with `windows-rs`.
|
||||
unsafe extern "system" fn wnd_proc(
|
||||
window: Foundation::HWND,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user