From 4524cbe8e3d9e367cf206da2b22d98c844a8a432 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 28 Apr 2019 13:55:30 -0400 Subject: [PATCH] Make drop work --- src/lib.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 23d5225..e414210 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -111,12 +111,12 @@ impl From for Error { } #[cfg(target_os = "windows")] -struct Windows(winrt::RuntimeContext); +struct Windows(Option); #[cfg(target_os = "windows")] impl Platform for Windows { fn setup() -> Self { - Windows(winrt::RuntimeContext::init()) + Windows(Some(winrt::RuntimeContext::init())) } fn notify(msg_title: &str, msg_body: &str) -> Result<(), Error> { @@ -150,8 +150,10 @@ impl Platform for Windows { #[cfg(target_os = "windows")] impl Drop for Windows { - fn drop(self) { - self.0.uninit(); + fn drop(&mut self) { + if let Some(runtime_context) = self.0.take() { + runtime_context.uninit(); + } } } -- 2.51.2