edgar-mtz-e / slimdx

Automatically exported from code.google.com/p/slimdx
0 stars 0 forks source link

Disposing of Surface from Device::GetBackBuffer results in exception when disposing Direct3D9::Device #433

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Direct3D9::GetBackBuffer(int, int) gets the Surface correctly but returns
Surface::FromPointer( buffer, this );

This is incorrect because it puts the Surface in the Device's owned object
table.  When the Surface is disposed the owned object table isn't cleaned
up.  This results in an exception when the Device itself is disposed
because it contains a (disposed) Surface in its list of m_Ancillary owned
objects.

Direct3D9::GetBackBuffer should return Surface::FromPointer( buffer ); instead.

Original issue reported on code.google.com by CRMeadow...@gmail.com on 15 Feb 2009 at 9:03

GoogleCodeExporter commented 9 years ago
This is the intended behavior; you should only Dispose() of what you create, 
the backbuffer is created implicitly 
for you. Before ancillary object tracking was adding, we could not provide that 
behavior and users had to dispose 
of the surface object obtained, even though this violates the IDisposable 
idiom. Since we added the tracking 
users should no longer dispose of objects that are not explicitly new'd.

Original comment by josh.petrie on 15 Feb 2009 at 11:23

GoogleCodeExporter commented 9 years ago
OK, not Disposing of the back buffer fixed the problem.  Direct3D9Manager in the
sample framework still Disposes of BackBuffers obtained this way.  Confusing.  
Maybe
need to fix that?

Original comment by CRMeadow...@gmail.com on 16 Feb 2009 at 12:14