Fix CA2216
This commit is contained in:
@@ -825,6 +825,9 @@ dotnet_diagnostic.CA2208.severity = warning
|
||||
# Dispose methods should call base class dispose.
|
||||
dotnet_diagnostic.CA2215.severity = warning
|
||||
|
||||
# Disposable types should declare finalizer.
|
||||
dotnet_diagnostic.CA2216.severity = warning
|
||||
|
||||
# Override GetHashCode on overriding Equals.
|
||||
dotnet_diagnostic.CA2218.severity = warning
|
||||
|
||||
|
||||
@@ -19,9 +19,10 @@ namespace OpenRA.Platforms.Default
|
||||
sealed class Sdl2GraphicsContext : ThreadAffine, IGraphicsContext
|
||||
{
|
||||
readonly Sdl2PlatformWindow window;
|
||||
bool disposed;
|
||||
IntPtr context;
|
||||
|
||||
public string GLVersion => OpenGL.Version;
|
||||
|
||||
public Sdl2GraphicsContext(Sdl2PlatformWindow window)
|
||||
{
|
||||
this.window = window;
|
||||
@@ -269,10 +270,12 @@ namespace OpenRA.Platforms.Default
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (disposed)
|
||||
return;
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
disposed = true;
|
||||
void Dispose(bool _)
|
||||
{
|
||||
if (context != IntPtr.Zero)
|
||||
{
|
||||
SDL.SDL_GL_DeleteContext(context);
|
||||
@@ -280,6 +283,9 @@ namespace OpenRA.Platforms.Default
|
||||
}
|
||||
}
|
||||
|
||||
public string GLVersion => OpenGL.Version;
|
||||
~Sdl2GraphicsContext()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +45,12 @@ namespace OpenRA.Platforms.Default
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
void Dispose(bool _)
|
||||
{
|
||||
if (Cursor != IntPtr.Zero)
|
||||
{
|
||||
@@ -58,5 +64,10 @@ namespace OpenRA.Platforms.Default
|
||||
surface = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
~Sdl2HardwareCursor()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user