Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

Access Violation using shared_ptr's...

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

If you intended to correct an error in the post then please contact us.

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
}


Let's call it a day. fighting it all day. Please help
Thanks
Jack

Share this post


Link to post
Share on other sites
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? Edited by BitMaster

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!