Access Violation using shared_ptr's...

Started by
1 comment, last by Brother Bob 11 years, 7 months ago

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
}


Let's call it a day. fighting it all day. Please help
Thanks
Jack
Advertisement
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?
I have brought up an issue in your other thread concerning smart pointers that you should take a look at.

This topic is closed to new replies.

Advertisement