Memory error adding getGuiElementByID to Irrlicht core

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Memory error adding getGuiElementByID to Irrlicht core

Post by saigumi »

Ok, I added getGuiElementByID to the Irrlicht core, using the same process and getSceneNodebyID.

When I make a call to the get function, it looks like it stomps something somewhere, but I can't find it after 3 hours of fiddling.

So, if anyone with fresh eyes can find it, I will be extremely grateful.

This is my caller function

Code: Select all

/*----------------------------------------------------------------------------------------------
Register a GUI Element by ID
----------------------------------------------------------------------------------------------*/
irr::gui::IGUIElement* GUIHandler::RegisterGUIElement(irr::s32 ID) {
	return guienv->getGUIElementFromId(ID);
}
And this is the code: http://www.saigumi.net/getbyid.zip
Crud, how do I do this again?
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post by saigumi »

Ah-ha! Figured it out... and fixed a problem in Irrlicht's CSceneManager.cpp as well.

Ok, In CSceneManager.cpp:

Code: Select all

	const core::list<ISceneNode*> list = start->getChildren();
	core::list<ISceneNode*>::Iterator it = list.begin();
	for (; it!=list.end(); ++it)
This causes a list to be created. When the list goes out of scope, the destructor for the list is called, wiping the contents of the list.

So, I just changed it to a reference

Code: Select all

	core::list<ISceneNode*>::Iterator it = start->getChildren().begin();
	for (; it!=start->getChildren().end(); ++it)
Now that I got that working...
Crud, how do I do this again?
Post Reply