Fix leak in canvas code and samples #60

Merged
MartinFouilleul merged 3 commits from fix_canvas_leak into main 2023-08-23 14:33:22 +00:00
1 changed files with 8 additions and 4 deletions
Showing only changes of commit 98f131cb30 - Show all commits

View File

@ -52,6 +52,8 @@ void oc_mtl_surface_destroy(oc_surface_data* interface)
}
void oc_mtl_surface_acquire_command_buffer(oc_mtl_surface* surface)
{
@autoreleasepool
{
if(surface->commandBuffer == nil)
{
@ -59,6 +61,7 @@ void oc_mtl_surface_acquire_command_buffer(oc_mtl_surface* surface)
[surface->commandBuffer retain];
}
}
}
void oc_mtl_surface_acquire_drawable(oc_mtl_surface* surface)
{
@ -102,8 +105,9 @@ void oc_mtl_surface_present(oc_surface_data* interface)
[surface->commandBuffer presentDrawable:surface->drawable];
[surface->drawable release];
surface->drawable = nil;
}
[surface->commandBuffer commit];
}
[surface->commandBuffer release];
surface->commandBuffer = nil;
}