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