Bug in FileChooser [WIN]


File filters we can pass to FileChooser class aren’t applied correctly (on Windows) which you can check for example in Code Editor demo (C++ file patterns don’t work during opening a file).

There is little bug in FileChooser::showPlatformDialog(). In juce_win32_FileChooser.cpp at line 235 filters are copied to OPENFILENAMEW structure:

        filter.copyToUTF16 (filters + (bytesWritten / sizeof (WCHAR)) + 1,
                            (int) ((filterSpaceNumChars - 1) * sizeof (WCHAR) - bytesWritten));

and “+ 1” in the destination makes that filter description and filter pattern are split by two null characters not by one. After removing ‘+ 1’ everything seems to be fine.

I’m using the latest (modules) tip.


Ah! Thanks, yes, copyToUTF16 returns a size that already includes the terminating null… Will get that sorted out for you!