Browse Source

vulkan: fix crash on quit if no window has been created.

Sasha Szpakowski 7 months ago
parent
commit
f0a7a19ebc
1 changed files with 17 additions and 3 deletions
  1. 17 3
      src/modules/graphics/vulkan/Graphics.cpp

+ 17 - 3
src/modules/graphics/vulkan/Graphics.cpp

@@ -3241,9 +3241,23 @@ void Graphics::cleanup()
 		vkDestroyFramebuffer(device, entry.second, nullptr);
 		vkDestroyFramebuffer(device, entry.second, nullptr);
 	framebuffers.clear();
 	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()
 void Graphics::cleanupSwapChain()