Unexpected behavior with opendialog box

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
Akabane87
Posts: 50
Joined: Sat May 05, 2012 6:11 pm

Unexpected behavior with opendialog box

Post by Akabane87 »

Hi there, it's me again, back with a new gui bug :D .

I have had a really hard time trying to figure why irrlicht crashed apparently randomly when validating a file in my favorite open dialog box.

I finally succeded in figuring what happened really. It's definitly odd :
When I create an opendialog box, select a file and validate it, i receive an event called EGET_FILE_SELECTED. If I select nothing or a directory, I get the event EGET_DIRECTORY_SELECTED.
But now if I select a file but move the cursor a little while holding the left mouse pressed (but stay on the selected item when released = very small displacement while pressed), I receive both events ; 1st is the EGET_DIRECTORY_SELECTED and then the EGET_FILE_SELECTED one.
The only way to differenciate (hopefully there is one to let me handle this unexpected event) a real directory selection from a wrong directory selection is the function that get the file which is not an empty string in my case.

Where I call this unexpected is that I handle the case where I get a directory selected by doing some stuff (batching all file of the directory) and then remove my opendialog box (what is not done by default when the event EGET_DIRECTORY_SELECTED is received. And when the engine want to send me the 2nd event EGET_FILE_SELECTED, it simply crashes because the element doesn't exists anymore. I don't really know (i haven't checked the code for this error) why we get the event EGET_DIRECTORY_SELECTED when selecting a file with a mini drag&drop by mistake, but this mistake occures enough times to ask for a fix.
CuteAlien
Admin
Posts: 9652
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Unexpected behavior with opendialog box

Post by CuteAlien »

Definitely not what it should do, thanks for reporting. Got unfortunately already a bunch of open bugreports on my todo and currently a little trouble finding time for it. But I'll try to get to it in a few weeks.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Akabane87
Posts: 50
Joined: Sat May 05, 2012 6:11 pm

Re: Unexpected behavior with opendialog box

Post by Akabane87 »

I don't know if this has been fixed or not finally, but I used this trick to filter out the bad bad event :

Code: Select all

case gui::EGET_DIRECTORY_SELECTED:
            /********************************* ANTI BUG *****************************************/
            if(wcslen(((gui::IGUIFileOpenDialog*)event.GUIEvent.Caller)->getFileName()) != 0)// we have selected a file, not a directory
            {
                break;// do nothing : we'll get soon the correct file selected event
            }
            /********************************* ANTI BUG *****************************************/
            else if ( event.GUIEvent.Caller == Context.spritebanklist->m_OpenFileDlg )
            {
                                // code handling the directory selection
            }
            else // [...]
CuteAlien
Admin
Posts: 9652
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Unexpected behavior with opendialog box

Post by CuteAlien »

Thanks for the workaround. And no - never got to this (is still pretty far down on my todo-list unfortunately).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply