mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 16:35:28 +00:00
Improved the Disposable pattern (finalizer was not needed).
Removed Dispose() call from glWindow_Destroy function. Added obsolete warning to the Create and OnCreate events/methods.
This commit is contained in:
parent
e8ec478237
commit
1d72cb7ab9
|
@ -64,7 +64,7 @@ namespace OpenTK
|
||||||
this.isExiting = true;
|
this.isExiting = true;
|
||||||
this.OnDestroy(EventArgs.Empty);
|
this.OnDestroy(EventArgs.Empty);
|
||||||
glWindow.Destroy -= glWindow_Destroy;
|
glWindow.Destroy -= glWindow_Destroy;
|
||||||
this.Dispose();
|
//this.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void glWindow_CreateInputDriver(object sender, EventArgs e)
|
void glWindow_CreateInputDriver(object sender, EventArgs e)
|
||||||
|
@ -224,12 +224,14 @@ namespace OpenTK
|
||||||
|
|
||||||
#region OnCreate
|
#region OnCreate
|
||||||
|
|
||||||
|
[Obsolete("The Create event is obsolete and will be removed on later versions. Use the Load event instead.")]
|
||||||
public event CreateEvent Create;
|
public event CreateEvent Create;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Raises the Create event. Override in derived classes to initialize resources.
|
/// Raises the Create event. Override in derived classes to initialize resources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
|
[Obsolete("The OnCreate method is obsolete and will be removed on later versions. Use the OnLoad method instead.")]
|
||||||
public virtual void OnCreate(EventArgs e)
|
public virtual void OnCreate(EventArgs e)
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Firing GameWindow.Create event");
|
Debug.WriteLine("Firing GameWindow.Create event");
|
||||||
|
@ -582,7 +584,6 @@ namespace OpenTK
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Dispose(bool manual)
|
private void Dispose(bool manual)
|
||||||
|
@ -590,10 +591,16 @@ namespace OpenTK
|
||||||
if (!disposed)
|
if (!disposed)
|
||||||
{
|
{
|
||||||
// Is this safe? Maybe 'Debug' has been disposed, too...
|
// Is this safe? Maybe 'Debug' has been disposed, too...
|
||||||
Debug.Print("{0} disposing GameWindow.", manual ? "Manually" : "Automatically");
|
//Debug.Print("{0} disposing GameWindow.", manual ? "Manually" : "Automatically");
|
||||||
|
|
||||||
if (manual)
|
if (manual)
|
||||||
{
|
{
|
||||||
|
if (driver != null)
|
||||||
|
{
|
||||||
|
driver.Dispose();
|
||||||
|
driver = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (glWindow != null)
|
if (glWindow != null)
|
||||||
{
|
{
|
||||||
glWindow.Dispose();
|
glWindow.Dispose();
|
||||||
|
@ -604,11 +611,6 @@ namespace OpenTK
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~GameWindow()
|
|
||||||
{
|
|
||||||
Dispose(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue