Clean up properly in case constructor throws

This commit is contained in:
Benau 2022-04-17 14:42:36 +08:00
parent 22f658239f
commit 3d6c86d04e

View File

@ -539,6 +539,9 @@ GEVulkanDriver::GEVulkanDriver(const SIrrlichtCreationParameters& params,
os::Printer::log("Vulkan driver version", getDriverVersionString().c_str());
for (const char* ext : m_device_extensions)
os::Printer::log("Vulkan enabled extension", ext);
try
{
GEVulkanCommandLoader::init(this);
createCommandBuffers();
@ -548,6 +551,12 @@ GEVulkanDriver::GEVulkanDriver(const SIrrlichtCreationParameters& params,
GEVulkan2dRenderer::init(this);
createUnicolorTextures();
GEVulkanFeatures::printStats();
}
catch (std::exception& e)
{
destroyVulkan();
throw std::runtime_error("GEVulkanDriver constructor failed");
}
} // GEVulkanDriver
// ----------------------------------------------------------------------------