Page 1 of 1

Unexpected behavior with opendialog box

Posted: Sun Feb 10, 2013 9:30 pm
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.

Re: Unexpected behavior with opendialog box

Posted: Mon Feb 11, 2013 11:01 am
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.

Re: Unexpected behavior with opendialog box

Posted: Wed Apr 02, 2014 7:29 am
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 // [...]

Re: Unexpected behavior with opendialog box

Posted: Wed Apr 02, 2014 12:54 pm
by CuteAlien
Thanks for the workaround. And no - never got to this (is still pretty far down on my todo-list unfortunately).