<AWT Dev> [8] Review request for 8021943: FileDialog getFile returns corrupted string after previous setFile

Alexander Zvegintsev alexander.zvegintsev at oracle.com
Thu Aug 1 10:03:57 PDT 2013


Hello,

Could you please review a fix for the following issue:
http://bugs.sun.com/view_bug.do?bug_id=8021943

The fix is available at:
http://cr.openjdk.java.net/~serb/8021943/webrev.00/

lpstrFile should be treated as double NULL terminated (DNT) string only 
when OFN_ALLOWMULTISELECT flag is set.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms646839%28v=vs.85%29.aspx
> If the *OFN_ALLOWMULTISELECT* flag is set and the user selects 
> multiple files, the buffer contains the current directory followed by 
> the file names of the selected files. For Explorer-style dialog boxes, 
> the directory and file name strings are *NULL* separated, with an 
> extra *NULL* character after the last file name. 
Currently we check length of a lpstrFile with GetBufferLength() which 
treats \0\0 as an end of a string.
It works nice, unless we call setFile() with a filename longer than a 
path of a saved file (in single-select mode).
In single-select mode lpstrFile string ends with single \0, and 
GetBufferLength() fails to find correct length and we pass \0-separated 
buffer to
WFileDialogPeer.handleSelected()  which will be treated as multi-select 
mode.

-- 
Thanks,

Alexander.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/awt-dev/attachments/20130801/e7700c2a/attachment.html 


More information about the awt-dev mailing list