From c8dcbc17013153d7b26d092f0c9a51ff75ff24d6 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Tue, 21 Apr 2020 16:43:31 -0700 Subject: [PATCH] Fix panic when no vulkan extensions are required --- src/compositor/mod.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/compositor/mod.rs b/src/compositor/mod.rs index 914c4b7..ef3806e 100644 --- a/src/compositor/mod.rs +++ b/src/compositor/mod.rs @@ -21,10 +21,12 @@ use super::*; impl Compositor { pub fn vulkan_instance_extensions_required(&self) -> Vec { - let temp = unsafe { + let temp = match unsafe { get_string(|ptr, n| self.0.GetVulkanInstanceExtensionsRequired.unwrap()(ptr, n)) - } - .unwrap(); + } { + Some(x) => x, + None => return Vec::new(), + }; temp.as_bytes() .split(|&x| x == b' ') .map(|x| CString::new(x.to_vec()).expect("extension name contained null byte")) @@ -36,10 +38,12 @@ impl Compositor { &self, physical_device: *mut VkPhysicalDevice_T, ) -> Vec { - let temp = get_string(|ptr, n| { + let temp = match get_string(|ptr, n| { self.0.GetVulkanDeviceExtensionsRequired.unwrap()(physical_device, ptr, n) - }) - .unwrap(); + }) { + Some(x) => x, + None => return Vec::new(), + }; temp.as_bytes() .split(|&x| x == b' ') .map(|x| CString::new(x.to_vec()).expect("extension name contained null byte"))