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

Anthony Petrov anthony.petrov at oracle.com
Tue Aug 13 03:24:59 PDT 2013


Hi Alexander,

Please add a comment to the bug report with your evaluation. I suggest 
to always do that before sending out a fix for review.

The fix itself looks fine to me.

--
best regards,
Anthony

On 08/01/2013 09:03 PM, Alexander Zvegintsev wrote:
> 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.
>


More information about the awt-dev mailing list