Jump to content
  • Advertisement
Sign in to follow this  
xegoth

Class causing fatal exception?

This topic is 5416 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

Alright I've got kind of a strange fatal exception crash. Here's the class that causes it:
class ParticleSys : public CBase
{

private: 
	
	LPDIRECT3DVERTEXBUFFER9 m_particleVertexBuffer;
	Particle g_particles[200];
	double dStartAppTime;
public:
	bool isActive;


public:
	LPDIRECT3DTEXTURE9 m_texParticle;
	void initPointSprites( LPDIRECT3DDEVICE9 m_pD3DDevice);
	void begin(float originX, float originY, float originZ);
	void updatePointSprites( void );
	void renderPointSprites( LPDIRECT3DDEVICE9 m_pD3DDevice );
	D3DXVECTOR3 getRandomVector( void );
	float getRandomMinMax( float fMin, float fMax );

	// Constructor - Sets the default variables for the particle system
	ParticleSys()
	{
		dStartAppTime = 0;
		isActive = false;
	}
	// Destructor - cleans up behind itself
	~ParticleSys()
	{
		SafeRelease(m_particleVertexBuffer); // Crashes the program
	
	}


};

Okay when I just create one object of that class it works fine. But if I declare a second one, the program crashes when I exit on the SafeRelease line.. Saferelease is defined as: #define SafeRelease(pInterface) if(pInterface != NULL) {pInterface->Release(); pInterface=NULL;} Any idea why creating a second object of that class type causes a crash? I think my so-so understanding of classes is coming back to haunt me.

Share this post


Link to post
Share on other sites
Advertisement
You never assign a value to m_particleVertexBuffer, so you are using an uninitialized pointer. It is possible that the first time the value is 0, and nothing happens.

Share this post


Link to post
Share on other sites
I fixed it, it was because I never assigned values to the stuff I was safdeleting, so the debugger or whatever assigned random crap to it, then I ended up using safedelete on something I that wasn't mine. BOOM!

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!