deconstructing exceptions woes...

Started by
2 comments, last by LogSoulz 22 years, 9 months ago
Hello, I''m having trouble with deconstructing my SceneGraph class. Exception would be thrown, why I don''t know... Help me out here ya''ll. my class hierarchy: I have 3 classes KSceneGraph, KTransformNode, and KGeoNode derived from KObject class. KSceneGraph contains a list of KTransformNodes and KtransformNodes contain a leaf node which is a KGeoNode object. Here is a simple console program to illustrate my problem:

KSceneGraph root;

int main()
{
	

	char text_1[50];
	char text_2[50];
	char text_3[50];

	KTransformNode* node;
	
	node = new KTransformNode();
	node->init();

	root.attachTransformNode(node);

	
	delete node; //throws exception here...



	return 0;

}

 
And the part that is the problem...this is where the debugers get stuck at...

KTransformNode::~KTransformNode()
{

	
	while(head->next !=NULL)
	{
		current = head->next;
		head->next = current->next;
		delete current;
	}
	
	delete GeoNode;
	
	delete head;


}
 
All help appreciated.
"Stop thrownin crap at my dome..."-My drunk room mate 4/20 2000
Advertisement
What''s the exception description?
Which line is it thrown from?
What are the values of all the variables on that line?
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
What are ''head'' and ''current'' in your KTransformNode destructor?

Are the aLso KTransformNodes?

When you construct whatever it is, are you setting the ->next value to NULL initially? If you do not set it to NULL in the beginning, when you do if (head->next != NULL) it will most likely still pass even if it was never assigned a node. So you will be trying to destruct something that is not really there.

Otherwise I would use Run To Cursor in Debug to the first line of the destructor and step through, checking the values of each pointer before it is destructed.

Seeya
Krippy
Thanks!

I fixed it. Seems like it was caused by the ordering or the deconstruction(whatever that means), so I implemented a free_node method which does the desconstruction, and it works! Yay, it feels so good after a long session of bug slaying, and heck no I don't like bugs. I sound like they're my friends or something, anyway to the coffee machine!

node->free_nodes();delete node;      


Edited by - LogSoulz on June 29, 2001 9:09:07 PM
"Stop thrownin crap at my dome..."-My drunk room mate 4/20 2000

This topic is closed to new replies.

Advertisement