FNA-XNA/FNA

AccessViolationException when window is closed

Opened this issue · 2 comments

RenderTarget2D.cs:

protected override void Dispose(bool disposing)
		{
			if (!IsDisposed)
			{
				if (glColorBuffer != IntPtr.Zero)
				{
					FNA3D.FNA3D_AddDisposeRenderbuffer(
						GraphicsDevice.GLDevice,
						glColorBuffer
					);
				}

				if (glDepthStencilBuffer != IntPtr.Zero)
				{
					FNA3D.FNA3D_AddDisposeRenderbuffer(      <<< EXCEPTION HERE
						GraphicsDevice.GLDevice,
						glDepthStencilBuffer
					);
				}
			}
			base.Dispose(disposing);
		}

Before exception occurs glColorBuffer is zero but glDepthStencilBuffer is not zero

As well, another exception:

"External component has thrown an exception." (HRESULT -2147467259)
   in Microsoft.Xna.Framework.Graphics.FNA3D.FNA3D_AddDisposeTexture(IntPtr device, IntPtr texture)
   in Microsoft.Xna.Framework.Graphics.Texture.Dispose(Boolean disposing) in C:\Users\Sergey\source\repos\Wosb\FNA_net7_0\src\Graphics\Texture.cs:line 49
   in Microsoft.Xna.Framework.Graphics.RenderTarget2D.Dispose(Boolean disposing) in C:\Users\Sergey\source\repos\Wosb\FNA_net7_0\src\Graphics\RenderTarget2D.cs:line 198
   in Microsoft.Xna.Framework.Graphics.GraphicsResource.Dispose() in C:\Users\Sergey\source\repos\Wosb\FNA_net7_0\src\Graphics\GraphicsResource.cs:line104
   in TheraEngine.Graphics.RenderTarget.Dispose()

Sounds like resources are leaking - are all graphics resources being disposed when the Game is disposing?