Calling SAFE_RELEASE(m_pd3dDevice) causes an access violation
This is really strange and I've never had this problem, but calling SAFE_RELEASE(m_pd3dDevice) causes an access violation. Could anybody point out why this is happening. Thanks.
You've most likely trashed the m_pd3dDevice pointer, or its been 'Release'd more times than its been 'AddRef'ed.
Make sure to initialize the pointer to NULL before you use it. You might be calling SAFE_RELEASE before the device creation?
Quote:Original post by jonnii
are you trying to delete from a different dll or something?
This should never be a problem, because you don't actually delete yourself. Release() does, internally. So it doesn't make a difference, AFAIK, as to where you're calling from.
I believe the call to m_pd3dDevice->Release() returns the number of references that the device still has. You can check by doing something like this:
DWORD Result = m_pd3dDevice->Release();
The result should be zero when you are releasing the device.
DWORD Result = m_pd3dDevice->Release();
The result should be zero when you are releasing the device.
Quote:Original post by _Phalanx_
what about
if(m_pD3DDevice)
m_pD3DDevice->Release();
wouldnt that do the same thing? try it
This is the SAFE_RELEASE macro:
#define SAFE_RELEASE(p){if(p)p->Release();p=0;}
I guess I should've explained better :) The device is created properly and it even renders the scene. But during the cleanup phase, calling SAFE_RELEASE(...) causes an access violation. The strange thing is that when I run the app through visual studio, it runs fine and exits fine, but when I "directly" run the app, it gives the access violation on exit.
The whole "thing" is encapsulated in a dll so I was wondering if that would affect things, doesn't make sense, yet...
Anyway, calling SAFE_RELEASE(...) when the device hasn't been created shouldn't give any problems since m_pd3dDevice would be NULL and the macro would simply ignore the call.
Thanks for the replies guys, I appreciate it. Any more ideas?
The whole "thing" is encapsulated in a dll so I was wondering if that would affect things, doesn't make sense, yet...
Anyway, calling SAFE_RELEASE(...) when the device hasn't been created shouldn't give any problems since m_pd3dDevice would be NULL and the macro would simply ignore the call.
Thanks for the replies guys, I appreciate it. Any more ideas?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement