PDA

View Full Version : QT3-getOpenFileName() "Look in:" Dropdown dialog not staying down + TempWmicBatchFile



liladas
29th July 2010, 18:49
I have a piece of QT3 Software.
All of the Open File dialogs are affected by this bug/behavior. All other SW on the machine does not have this behavior.

When I call "QFileDialog::getOpenFileName()" it brings up the native windows file dialog as expected. Notice the dropdown at the top labeled "Look in:" that shows the directory tree. Once I navigate to "Desktop" or "My Documents" I can not keep this dropdown to stay open. It closes on me within 2-3 seconds, repeatably -- rendering it useless and annoying.
I've also noticed that a empty file named "TempWmicBatchFile.bat" gets left behind in each directory I navigate to. While in a directory, this "TempWmicBatchFile.bat" is updated with a new timestamp (or deleted newly generated?) every few seconds.

I have no idea how to go about fixing this. Any thoughts?
Using the windows system calls and the "OPENFILENAME ofn" struct instead of the Qt call results in the same problem. Qt3's own QFileDialog works just fine and will be used if I can't find a solution, I just don't like the look/feel of it.

squidge
29th July 2010, 18:58
TempWmicBatchFile.bat is created by WMIC (Windows Management Instrumentation Command-line). You should be able to delete such files without problems.

"Desktop" and "My Documents" require OLE typically and function strangely if it isn't already initialised. Maybe a call to "::OleInitialize(NULL);" in your main code will help?

liladas
29th July 2010, 19:37
So I went ahead and tried adding the "::OleInitialize(NULL)" as well as "::OleUninitialize()", once to the main portion of code, and then right before the dialog. None of the combinations I tried seemed to have an effect.

I did notice that once the "TempWmicBatchFile.bat" is created, if I set it to ReadOnly permissions, it solves the problem -- the dropdown stays down. So I think it has something to do with the fact the batch file is being updated. Maybe the drop down wants to refresh when it notices changes? Is there someway to suppress or solve the creation/deletion of this file?
Note that if I delete the file, it is created again if I'm still browsing that directory.