diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bd13e24ce8..be6973dff4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -181,6 +181,7 @@ Passing an owned value `window` to `Surface` will return a `Surface<'static>`. S - `BufferMappedRange` trait is now `WasmNotSendSync`, i.e. it is `Send`/`Sync` if not on wasm or `fragile-send-sync-non-atomic-wasm` is enabled. By @wumpf in [#4818](https://github.com/gfx-rs/wgpu/pull/4818) - Align `wgpu_types::CompositeAlphaMode` serde serialization to spec. By @littledivy in [#4940](https://github.com/gfx-rs/wgpu/pull/4940) - Fix error message of `ConfigureSurfaceError::TooLarge`. By @Dinnerbone in [#4960](https://github.com/gfx-rs/wgpu/pull/4960) +- Fix dropping of `DeviceLostCallbackC` params. By @bradwerth in [#5032](https://github.com/gfx-rs/wgpu/pull/5032) #### DX12 diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index bb0afedafc5..10e8f401415 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -294,7 +294,7 @@ impl DeviceLostClosure { /// /// - Both pointers must point to `'static` data, as the callback may happen at /// an unspecified time. - pub unsafe fn from_c(closure: DeviceLostClosureC) -> Self { + pub unsafe fn from_c(mut closure: DeviceLostClosureC) -> Self { // Build an inner with the values from closure, ensuring that // inner.called is false. let inner = DeviceLostClosureC { @@ -302,6 +302,10 @@ impl DeviceLostClosure { user_data: closure.user_data, called: false, }; + + // Mark the original closure as called, so we can safely drop it. + closure.called = true; + Self { inner: DeviceLostClosureInner::C { inner }, }