Skip to content

Commit 544b647

Browse files
authored
Dispose Glfw/Sdl When Checking if Applicable (dotnet#2352)
* Dispose Glfw when Checking if Applicable * Dispose Sdl when Checking if Applicable
1 parent d2871a6 commit 544b647

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/Windowing/Silk.NET.Windowing.Glfw/GlfwPlatform.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,10 @@ internal class GlfwPlatform : IWindowPlatform
2323
(
2424
() =>
2525
{
26+
GLFW.Glfw? api = null;
2627
try
2728
{
28-
GLFW.Glfw.GetApi(); // activate the class so we can determine if we can activate the class
29+
api = GLFW.Glfw.GetApi(); // activate the class so we can determine if we can activate the class
2930
}
3031
catch (Exception ex)
3132
{
@@ -34,6 +35,10 @@ internal class GlfwPlatform : IWindowPlatform
3435
#endif
3536
return false;
3637
}
38+
finally
39+
{
40+
api?.Dispose();
41+
}
3742

3843
return true;
3944
}

src/Windowing/Silk.NET.Windowing.Sdl/SdlPlatform.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ public static SdlPlatform GetOrRegister()
3434
(
3535
() =>
3636
{
37+
SDL.Sdl? api = null;
3738
try
3839
{
39-
SDL.Sdl.GetApi();
40+
api = SDL.Sdl.GetApi();
4041
}
4142
catch (Exception ex)
4243
{
@@ -45,6 +46,10 @@ public static SdlPlatform GetOrRegister()
4546
#endif
4647
return false;
4748
}
49+
finally
50+
{
51+
api?.Dispose();
52+
}
4853

4954
return true;
5055
}

0 commit comments

Comments
 (0)