From f0a7a19ebcb04927ff16ff420bfa20e1b4fa66a6 Mon Sep 17 00:00:00 2001 From: Sasha Szpakowski Date: Sat, 4 Jan 2025 16:19:30 -0400 Subject: [PATCH] vulkan: fix crash on quit if no window has been created. --- src/modules/graphics/vulkan/Graphics.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/modules/graphics/vulkan/Graphics.cpp b/src/modules/graphics/vulkan/Graphics.cpp index e388bae1a..4229d4bd2 100644 --- a/src/modules/graphics/vulkan/Graphics.cpp +++ b/src/modules/graphics/vulkan/Graphics.cpp @@ -3241,9 +3241,23 @@ void Graphics::cleanup() vkDestroyFramebuffer(device, entry.second, nullptr); framebuffers.clear(); - vkDestroyCommandPool(device, commandPool, nullptr); - vkDestroyPipelineCache(device, pipelineCache, nullptr); - vkDestroyDevice(device, nullptr); + if (commandPool != VK_NULL_HANDLE) + { + vkDestroyCommandPool(device, commandPool, nullptr); + commandPool = VK_NULL_HANDLE; + } + + if (pipelineCache != VK_NULL_HANDLE) + { + vkDestroyPipelineCache(device, pipelineCache, nullptr); + pipelineCache = VK_NULL_HANDLE; + } + + if (device != VK_NULL_HANDLE) + { + vkDestroyDevice(device, nullptr); + device = VK_NULL_HANDLE; + } } void Graphics::cleanupSwapChain()