The EditBox doesn't remove its focus in the guiEnvironment after it is removed from the scenegraph.
Compile the following code and select the editbox. Then hit enter twice.
If u uncomment "device->getGUIEnvironment()->setFocus(NULL);" it doesn't crash.
Code: Select all
#include <irrlicht.h>
irr::IrrlichtDevice *device;
irr::gui::IGUIElement* rem;
class events : public irr::IEventReceiver
{
public:
bool OnEvent(const irr::SEvent& event)
{
switch(event.EventType)
{
case irr::EET_GUI_EVENT:
switch(event.GUIEvent.EventType)
{
case irr::gui::EGET_EDITBOX_ENTER:
rem = device->getGUIEnvironment()->getRootGUIElement()->getElementFromId(555, true);
return true;
break;
}
break;
}
return false;
}
};
int main(int argc, char* argv[])
{
rem = NULL;
device = irr::createDevice(irr::video::EDT_OPENGL, irr::core::dimension2d<irr::s32>(640,480));
device->setEventReceiver(new events);
device->getGUIEnvironment()->addEditBox(L"TEST", irr::core::rect<irr::s32>(100,100,200,150), true, NULL/*device->getGUIEnvironment()->addWindow(irr::core::rect<irr::s32>(50,50,500,350))*/, 555);
while (device->run())
{
device->getVideoDriver()->beginScene(true, true, irr::video::SColor(255,0,0,0));
device->getGUIEnvironment()->drawAll();
device->getVideoDriver()->endScene();
if(rem)
{
//device->getGUIEnvironment()->setFocus(NULL);
rem->remove();
rem = NULL;
}
}
device->drop();
return 0;
}