Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan: Adding leak prevention if the fonts need to be recreated #6943

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions backends/imgui_impl_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,31 @@ bool ImGui_ImplVulkan_CreateFontsTexture(VkCommandBuffer command_buffer)

VkResult err;

if (bd->FontDescriptorSet) {
err = vkFreeDescriptorSets(v->Device, v->DescriptorPool, 1, &bd->FontDescriptorSet);
check_vk_result(err);
bd->FontDescriptorSet = VK_NULL_HANDLE;
}

// clean up before reallocating to avoid a resource leak
if (bd->FontView)
{
vkDestroyImageView(v->Device, bd->FontView, v->Allocator);
bd->FontView = VK_NULL_HANDLE;
}
if (bd->FontImage)
{
vkDestroyImage(v->Device, bd->FontImage, v->Allocator);
bd->FontImage = VK_NULL_HANDLE;
}
if (bd->FontMemory)
{
vkFreeMemory(v->Device, bd->FontMemory, v->Allocator);
bd->FontMemory = VK_NULL_HANDLE;
}
ImGui_ImplVulkan_DestroyFontUploadObjects();


// Create the Image:
{
VkImageCreateInfo info = {};
Expand Down