* Source/OpenTK/Platform/Egl/EglContext.cs:
* Source/OpenTK/Graphics/GraphicsContext.cs: * Source/OpenTK/Graphics/IGraphicsContext.cs: * Source/OpenTK/Platform/MacOS/AglContext.cs: * Source/OpenTK/Platform/X11/X11GLContext.cs: * Source/OpenTK/Graphics/GraphicsContextBase.cs: * Source/OpenTK/Platform/Windows/WinGLContext.cs: * Source/OpenTK/Platform/Dummy/DummyGLContext.cs: Added IsDisposed property to IGraphicsContext and implemented in all context classes. Removed 'bool disposed' fields from these classes in favor of the new property.
This commit is contained in:
parent
3822044e17
commit
95c88baf3d
8 changed files with 38 additions and 18 deletions
|
@ -301,13 +301,23 @@ namespace OpenTK.Graphics
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a System.Boolean indicating whether this Context is current in the calling thread.
|
||||
/// Gets a <see cref="System.Boolean"/> indicating whether this instance is current in the calling thread.
|
||||
/// </summary>
|
||||
public bool IsCurrent
|
||||
{
|
||||
get { return implementation.IsCurrent; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="System.Boolean"/> indicating whether this instance has been disposed.
|
||||
/// It is an error to access any instance methods if this property returns true.
|
||||
/// </summary>
|
||||
public bool IsDisposed
|
||||
{
|
||||
get { return disposed && implementation.IsDisposed; }
|
||||
private set { disposed = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether VSync is enabled.
|
||||
/// </summary>
|
||||
|
@ -397,7 +407,7 @@ namespace OpenTK.Graphics
|
|||
|
||||
void Dispose(bool manual)
|
||||
{
|
||||
if (!disposed)
|
||||
if (!IsDisposed)
|
||||
{
|
||||
Debug.Print("Disposing context {0}.", (this as IGraphicsContextInternal).Context.ToString());
|
||||
lock (context_lock)
|
||||
|
@ -410,7 +420,7 @@ namespace OpenTK.Graphics
|
|||
if (implementation != null)
|
||||
implementation.Dispose();
|
||||
}
|
||||
disposed = true;
|
||||
IsDisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,8 @@ namespace OpenTK.Graphics
|
|||
{
|
||||
#region Fields
|
||||
|
||||
bool disposed;
|
||||
|
||||
protected ContextHandle Handle;
|
||||
protected GraphicsMode Mode;
|
||||
|
||||
|
@ -50,6 +52,12 @@ namespace OpenTK.Graphics
|
|||
|
||||
public abstract bool IsCurrent { get; }
|
||||
|
||||
public bool IsDisposed
|
||||
{
|
||||
get { return disposed; }
|
||||
protected set { disposed = value; }
|
||||
}
|
||||
|
||||
public abstract bool VSync { get; set; }
|
||||
|
||||
public virtual void Update(IWindowInfo window) { }
|
||||
|
|
|
@ -31,10 +31,16 @@ namespace OpenTK.Graphics
|
|||
void MakeCurrent(IWindowInfo window);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a System.Boolean indicating whether the GraphicsContext is current in the calling thread.
|
||||
/// Gets a <see cref="System.Boolean"/> indicating whether this instance is current in the calling thread.
|
||||
/// </summary>
|
||||
bool IsCurrent { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="System.Boolean"/> indicating whether this instance has been disposed.
|
||||
/// It is an error to access any instance methods if this property returns true.
|
||||
/// </summary>
|
||||
bool IsDisposed { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether VSyncing is enabled.
|
||||
/// </summary>
|
||||
|
|
|
@ -89,7 +89,7 @@ namespace OpenTK.Platform.Dummy
|
|||
|
||||
#region --- IDisposable Members ---
|
||||
|
||||
public override void Dispose() { }
|
||||
public override void Dispose() { IsDisposed = true; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ namespace OpenTK.Platform.Egl
|
|||
EglWindowInfo WindowInfo;
|
||||
EGLContext HandleAsEGLContext { get { return new EGLContext(Handle.Handle); } set { Handle = new ContextHandle(value.Handle.Value); } }
|
||||
bool vsync = true; // Default vsync value is defined as 1 (true) in EGL.
|
||||
bool disposed = false;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -141,7 +140,7 @@ namespace OpenTK.Platform.Egl
|
|||
// thread?
|
||||
void Dispose(bool manual)
|
||||
{
|
||||
if (!disposed)
|
||||
if (!IsDisposed)
|
||||
{
|
||||
if (manual)
|
||||
{
|
||||
|
@ -152,7 +151,7 @@ namespace OpenTK.Platform.Egl
|
|||
{
|
||||
Debug.Print("[Warning] {0}:{1} was not disposed.", this.GetType().Name, HandleAsEGLContext.Handle);
|
||||
}
|
||||
disposed = true;
|
||||
IsDisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -335,8 +335,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
void Dispose(bool disposing)
|
||||
{
|
||||
|
||||
if (Handle.Handle == IntPtr.Zero)
|
||||
if (IsDisposed || Handle.Handle == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
Debug.Print("Disposing of AGL context.");
|
||||
|
@ -370,6 +369,8 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
throw new MacOSException((OSStatus)Agl.GetError(), Agl.ErrorString(Agl.GetError()));
|
||||
}
|
||||
|
||||
IsDisposed = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -32,8 +32,6 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
bool vsync_supported;
|
||||
|
||||
bool disposed;
|
||||
|
||||
#region --- Contructors ---
|
||||
|
||||
static WinGLContext()
|
||||
|
@ -305,7 +303,7 @@ namespace OpenTK.Platform.Windows
|
|||
|
||||
private void Dispose(bool calledManually)
|
||||
{
|
||||
if (!disposed)
|
||||
if (!IsDisposed)
|
||||
{
|
||||
if (calledManually)
|
||||
{
|
||||
|
@ -316,7 +314,7 @@ namespace OpenTK.Platform.Windows
|
|||
Debug.Print("[Warning] OpenGL context {0} leaked. Did you forget to call IGraphicsContext.Dispose()?",
|
||||
Handle.Handle);
|
||||
}
|
||||
disposed = true;
|
||||
IsDisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,8 +26,6 @@ namespace OpenTK.Platform.X11
|
|||
bool glx_loaded;
|
||||
GraphicsMode graphics_mode;
|
||||
|
||||
bool disposed;
|
||||
|
||||
#region --- Constructors ---
|
||||
|
||||
public X11GLContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shared, bool direct,
|
||||
|
@ -298,7 +296,7 @@ namespace OpenTK.Platform.X11
|
|||
|
||||
private void Dispose(bool manuallyCalled)
|
||||
{
|
||||
if (!disposed)
|
||||
if (!IsDisposed)
|
||||
{
|
||||
if (manuallyCalled)
|
||||
{
|
||||
|
@ -312,7 +310,7 @@ namespace OpenTK.Platform.X11
|
|||
{
|
||||
Debug.Print("[Warning] {0} leaked.", this.GetType().Name);
|
||||
}
|
||||
disposed = true;
|
||||
IsDisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue