diff --git a/src/Windowing/Silk.NET.Windowing.Glfw/GlfwPlatform.cs b/src/Windowing/Silk.NET.Windowing.Glfw/GlfwPlatform.cs index 7edeec4d09..f63dd5b94d 100644 --- a/src/Windowing/Silk.NET.Windowing.Glfw/GlfwPlatform.cs +++ b/src/Windowing/Silk.NET.Windowing.Glfw/GlfwPlatform.cs @@ -23,9 +23,10 @@ internal class GlfwPlatform : IWindowPlatform ( () => { + GLFW.Glfw? api = null; try { - GLFW.Glfw.GetApi(); // activate the class so we can determine if we can activate the class + api = GLFW.Glfw.GetApi(); // activate the class so we can determine if we can activate the class } catch (Exception ex) { @@ -34,6 +35,10 @@ internal class GlfwPlatform : IWindowPlatform #endif return false; } + finally + { + api?.Dispose(); + } return true; } diff --git a/src/Windowing/Silk.NET.Windowing.Sdl/SdlPlatform.cs b/src/Windowing/Silk.NET.Windowing.Sdl/SdlPlatform.cs index 04db4dcdf7..5114084f08 100644 --- a/src/Windowing/Silk.NET.Windowing.Sdl/SdlPlatform.cs +++ b/src/Windowing/Silk.NET.Windowing.Sdl/SdlPlatform.cs @@ -34,9 +34,10 @@ public static SdlPlatform GetOrRegister() ( () => { + SDL.Sdl? api = null; try { - SDL.Sdl.GetApi(); + api = SDL.Sdl.GetApi(); } catch (Exception ex) { @@ -45,6 +46,10 @@ public static SdlPlatform GetOrRegister() #endif return false; } + finally + { + api?.Dispose(); + } return true; }