mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-14 12:04:29 +00:00
example: ++gl, wgpu safety
Free the canvas in the reverse order of their creation.
This commit is contained in:
parent
8995bc32a2
commit
036d1e7cac
1 changed files with 8 additions and 2 deletions
|
@ -338,6 +338,10 @@ struct GlWindow : Window
|
|||
|
||||
virtual ~GlWindow()
|
||||
{
|
||||
//Free in the reverse order of their creation.
|
||||
delete(canvas);
|
||||
canvas = nullptr;
|
||||
|
||||
SDL_GL_DeleteContext(context);
|
||||
}
|
||||
|
||||
|
@ -425,8 +429,10 @@ struct WgWindow : Window
|
|||
|
||||
virtual ~WgWindow()
|
||||
{
|
||||
//the canvas is tightly relying on the wgpu resource. cut out before rleasing them for safety.
|
||||
static_cast<tvg :: WgCanvas*>(canvas)->target(nullptr, nullptr, nullptr, 0, 0);
|
||||
//Free in the reverse order of their creation.
|
||||
delete(canvas);
|
||||
canvas = nullptr;
|
||||
|
||||
wgpuSurfaceRelease(surface);
|
||||
wgpuInstanceRelease(instance);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue