mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
FileChooser: Avoid setting default extension to filename
Fixes a bug on Windows when opening a FileChooser with the following
arguments.
FileChooser ("",
"C:\path\to\file", // filename 'file' doesn't contain '.'
"", // all extensions are allowed
true);
The expected behaviour is that the initially-displayed filename is
"file".
The actual behaviour was that the initially-displayed filename was
"file.file".
This commit is contained in:
parent
95f823ff72
commit
8942f22a9b
1 changed files with 11 additions and 10 deletions
|
|
@ -581,19 +581,20 @@ private:
|
|||
|
||||
String getDefaultFileExtension (const String& filename) const
|
||||
{
|
||||
auto extension = filename.fromLastOccurrenceOf (".", false, false);
|
||||
const auto extension = filename.contains (".") ? filename.fromLastOccurrenceOf (".", false, false)
|
||||
: String();
|
||||
|
||||
if (extension.isEmpty())
|
||||
{
|
||||
auto tokens = StringArray::fromTokens (filtersString, ";,", "\"'");
|
||||
tokens.trim();
|
||||
tokens.removeEmptyStrings();
|
||||
if (! extension.isEmpty())
|
||||
return extension;
|
||||
|
||||
if (tokens.size() == 1 && tokens[0].removeCharacters ("*.").isNotEmpty())
|
||||
extension = tokens[0].fromFirstOccurrenceOf (".", false, false);
|
||||
}
|
||||
auto tokens = StringArray::fromTokens (filtersString, ";,", "\"'");
|
||||
tokens.trim();
|
||||
tokens.removeEmptyStrings();
|
||||
|
||||
return extension;
|
||||
if (tokens.size() == 1 && tokens[0].removeCharacters ("*.").isNotEmpty())
|
||||
return tokens[0].fromFirstOccurrenceOf (".", false, false);
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue