From 7258a7c2366d6e9e5472e9e420708fcee790a9cb Mon Sep 17 00:00:00 2001 From: Maik Klein Date: Wed, 21 Oct 2020 21:07:18 +0200 Subject: [PATCH] Don't panic when destroying debug utils (#79) * Don't panic when destroying debug utils * Use zip instead of two branches Co-authored-by: Jasper Bekkers Co-authored-by: Jasper Bekkers --- examples/example-runner/src/main.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/example-runner/src/main.rs b/examples/example-runner/src/main.rs index da793ae2fa..7512dedd11 100644 --- a/examples/example-runner/src/main.rs +++ b/examples/example-runner/src/main.rs @@ -631,13 +631,13 @@ impl Drop for ExampleBase { .destroy_swapchain(self.swapchain, None); self.device.destroy_device(None); self.surface_loader.destroy_surface(self.surface, None); - // just let them leak for now - /* - self.debug_utils_loader - .take() - .unwrap() - .destroy_debug_utils_messenger(self.debug_call_back.take().unwrap(), None); - */ + + if let Some((debug_utils, call_back)) = + Option::zip(self.debug_utils_loader.take(), self.debug_call_back.take()) + { + debug_utils.destroy_debug_utils_messenger(call_back, None); + } + self.instance.destroy_instance(None); } }