Access Violation using shared_ptr's...

This topic is 2300 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

 class CDemo : public D3DApp { vector<shared_ptr<CObject>> m_pRenderObjects; }; CDemo::CDemo { shared_ptr<CObject> wh(new CWarehouse()); m_pRenderObjects.push_back(wh); } CDemo::~CDemo { // Access Violation here } 
Thanks
Jack

Share on other sites
There is nothing wrong with the code given (except it would not compile like that). The error could be in any number of places, as usual for C++ programs (duplicate delete, trashed heap by writing over owned memory, etc., etc.).

One thing that sticks out is the naming of "m_pRenderObjects" and "D3DApp". Is it possible the D3DApp releases the DirectX interfaces before entering its destructor? In that case, deleting anything that still believes it holds DirectX interfaces that needs releasing (like a render object) will likely crash.
However, if that were the case I would expect the stacktrace of the crash being much closer to the source. You are debugging a debug build, are you not? Edited by BitMaster

Share on other sites
I have brought up an issue in your other thread concerning smart pointers that you should take a look at. Edited by Brother Bob

1. 1
2. 2
Rutin
19
3. 3
khawk
15
4. 4
A4L
14
5. 5

• 9
• 13
• 26
• 10
• 11
• Forum Statistics

• Total Topics
633744
• Total Posts
3013662
×