mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 07:35:27 +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.OnDestroy(EventArgs.Empty);
|
||||
glWindow.Destroy -= glWindow_Destroy;
|
||||
this.Dispose();
|
||||
//this.Dispose();
|
||||
}
|
||||
|
||||
void glWindow_CreateInputDriver(object sender, EventArgs e)
|
||||
|
@ -224,12 +224,14 @@ namespace OpenTK
|
|||
|
||||
#region OnCreate
|
||||
|
||||
[Obsolete("The Create event is obsolete and will be removed on later versions. Use the Load event instead.")]
|
||||
public event CreateEvent Create;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the Create event. Override in derived classes to initialize resources.
|
||||
/// </summary>
|
||||
/// <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)
|
||||
{
|
||||
Debug.WriteLine("Firing GameWindow.Create event");
|
||||
|
@ -582,7 +584,6 @@ namespace OpenTK
|
|||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void Dispose(bool manual)
|
||||
|
@ -590,10 +591,16 @@ namespace OpenTK
|
|||
if (!disposed)
|
||||
{
|
||||
// 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 (driver != null)
|
||||
{
|
||||
driver.Dispose();
|
||||
driver = null;
|
||||
}
|
||||
|
||||
if (glWindow != null)
|
||||
{
|
||||
glWindow.Dispose();
|
||||
|
@ -604,11 +611,6 @@ namespace OpenTK
|
|||
}
|
||||
}
|
||||
|
||||
~GameWindow()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue