fix: windows save dialog extension bug (#44770)
* fix: windows save dialog extension bug * refactor: simplify firstSpec extraction * refactor: split when necessary --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: nilaoda <nilaoda@live.com>
This commit is contained in:
parent
787d4c3859
commit
b6f97b7952
1 changed files with 6 additions and 2 deletions
|
@ -144,10 +144,14 @@ static void ApplySettings(IFileDialog* dialog, const DialogSettings& settings) {
|
||||||
// We set file extension to the first none-wildcard extension to make
|
// We set file extension to the first none-wildcard extension to make
|
||||||
// sure the dialog will update file extension automatically.
|
// sure the dialog will update file extension automatically.
|
||||||
for (size_t i = 0; i < filterspec.size(); ++i) {
|
for (size_t i = 0; i < filterspec.size(); ++i) {
|
||||||
if (std::wstring(filterspec[i].pszSpec) != L"*.*") {
|
std::wstring spec(filterspec[i].pszSpec);
|
||||||
|
if (spec != L"*.*") {
|
||||||
// SetFileTypeIndex is regarded as one-based index.
|
// SetFileTypeIndex is regarded as one-based index.
|
||||||
dialog->SetFileTypeIndex(i + 1);
|
dialog->SetFileTypeIndex(i + 1);
|
||||||
dialog->SetDefaultExtension(filterspec[i].pszSpec);
|
// "*.jpg;*.png" => "*.jpg"
|
||||||
|
std::wstring first_spec = spec.substr(0, spec.find(L';'));
|
||||||
|
// "*.jpg" => "jpg"
|
||||||
|
dialog->SetDefaultExtension(first_spec.substr(2).c_str());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue