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()
|
virtual ~GlWindow()
|
||||||
{
|
{
|
||||||
|
//Free in the reverse order of their creation.
|
||||||
|
delete(canvas);
|
||||||
|
canvas = nullptr;
|
||||||
|
|
||||||
SDL_GL_DeleteContext(context);
|
SDL_GL_DeleteContext(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -425,8 +429,10 @@ struct WgWindow : Window
|
||||||
|
|
||||||
virtual ~WgWindow()
|
virtual ~WgWindow()
|
||||||
{
|
{
|
||||||
//the canvas is tightly relying on the wgpu resource. cut out before rleasing them for safety.
|
//Free in the reverse order of their creation.
|
||||||
static_cast<tvg :: WgCanvas*>(canvas)->target(nullptr, nullptr, nullptr, 0, 0);
|
delete(canvas);
|
||||||
|
canvas = nullptr;
|
||||||
|
|
||||||
wgpuSurfaceRelease(surface);
|
wgpuSurfaceRelease(surface);
|
||||||
wgpuInstanceRelease(instance);
|
wgpuInstanceRelease(instance);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue