Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dispose SoundEffect and Texture2D (mainly RenderTarget2Ds) properly #860

Merged
merged 1 commit into from
Oct 15, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions MonoGame.Framework/Desktop/Audio/SoundEffectInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ public SoundEffectInstance()
InitializeSound();
}

~SoundEffectInstance()
{
Dispose();
}

public SoundEffectInstance (SoundEffect parent)
{
this.soundEffect = parent;
Expand Down Expand Up @@ -109,13 +114,16 @@ void HandleSoundBufferReserved (object sender, EventArgs e)
}

public void Dispose ()
{
this.Stop(true);
soundBuffer.Reserved -= HandleSoundBufferReserved;
soundBuffer.Recycled -= HandleSoundBufferRecycled;
soundBuffer.Dispose ();
soundBuffer = null;
isDisposed = true;
{
if (!isDisposed)
{
this.Stop(true);
soundBuffer.Reserved -= HandleSoundBufferReserved;
soundBuffer.Recycled -= HandleSoundBufferRecycled;
soundBuffer.Dispose();
soundBuffer = null;
isDisposed = true;
}
}

public void Apply3D (AudioListener listener, AudioEmitter emitter)
Expand Down
5 changes: 5 additions & 0 deletions MonoGame.Framework/Graphics/Texture2D.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,11 @@ public Texture2D(GraphicsDevice graphicsDevice, int width, int height)
{
}

~Texture2D()
{
Dispose();
}

public int Width
{
get
Expand Down