[fixed] EditBox crashbug

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

[fixed] EditBox crashbug

Post by sudi »

Edit: Irrlicht 1.5

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;
}
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

It was sending events to a null parent, this is now fixed in trunk.
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

thx
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Post Reply