From 036d1e7caca8bfababec152d477bbaa662a14143 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Mon, 25 Nov 2024 11:02:16 +0900 Subject: [PATCH] example: ++gl, wgpu safety Free the canvas in the reverse order of their creation. --- examples/Example.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/Example.h b/examples/Example.h index 49a7835b..f43a882b 100644 --- a/examples/Example.h +++ b/examples/Example.h @@ -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(canvas)->target(nullptr, nullptr, nullptr, 0, 0); + //Free in the reverse order of their creation. + delete(canvas); + canvas = nullptr; + wgpuSurfaceRelease(surface); wgpuInstanceRelease(instance); }