From 54bc41f68bc852fd220840dd4aa3c5f4369b70ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n?= Date: Mon, 20 Apr 2020 23:48:42 +0200 Subject: [PATCH] Implement `Drop` for `Proxy` on macOS platform (#1526) --- CHANGELOG.md | 1 + src/platform_impl/macos/event_loop.rs | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e428fbbe..ef5e9fd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - On X11, fix `ResumeTimeReached` being fired too early. - On Web, replaced zero timeout for `ControlFlow::Poll` with `requestAnimationFrame` - On Web, fix a possible panic during event handling +- On macOS, fix `EventLoopProxy` leaking memory for every instance. # 0.22.0 (2020-03-09) diff --git a/src/platform_impl/macos/event_loop.rs b/src/platform_impl/macos/event_loop.rs index cc3d3928..01437b84 100644 --- a/src/platform_impl/macos/event_loop.rs +++ b/src/platform_impl/macos/event_loop.rs @@ -117,6 +117,14 @@ pub struct Proxy { unsafe impl Send for Proxy {} +impl Drop for Proxy { + fn drop(&mut self) { + unsafe { + CFRelease(self.source as _); + } + } +} + impl Clone for Proxy { fn clone(&self) -> Self { Proxy::new(self.sender.clone())