I've got a strange problem with my event managing. This is my CEventManager derivated from IEventReceiver:
Code: Select all
typedef irr::core::array vector;
All events, which are received in OnEvent are saved in an Irrlicht Array.
Code: Select all
bool CEventManager::OnEvent(SEvent event)
{
SEvent *evTmp = new SEvent;
*evTmp = event;
this->vLastEvents->push_back(evTmp);
return false;
};
In my program's main loop, I check all events, saved in CEventManager::vLastEvents like this
Code: Select all
vector<SEvent*> *vEvents = this->emEventManager->getLastEvents();
for (unsigned int i = 0; i < vEvents->size(); ++i)
{
SEvent *evTmp = (*vEvents)[i];
if ( (evTmp->EventType == EET_GUI_EVENT) && (evTmp->GUIEvent.Caller->getID() == this->buStarten->getID()) && (evTmp->GUIEvent.EventType == EGET_BUTTON_CLICKED) )
{
__LOG("[Spiel Starten]");
bRun = false;
}
this->emEventManager->dropList();
In the first run, everythink went perfect, the events were saved and evaluated. So if I press the button (IGUIButton buStarten), the CGame object will be destroyed and new created.
But in the second run the program crashes if I make a GUI Event (like pressing the button).
It crashes with this
Code: Select all
evTmp->GUIEvent.Caller->getID()
Can somebody please help me and tell me, why this doesn't work or why the pointer is right in the OnEvent method of the CEventManager and wrong in the main loop of the CGame object?