X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/926df8a162ac02ccb102733c2c86d2cd50341d7e..92d00a3615b1e598cac48b2f608be1bf32b27057:/src/gtk/filedlg.cpp diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index 6f3b775ada..6d36d6364e 100644 --- a/src/gtk/filedlg.cpp +++ b/src/gtk/filedlg.cpp @@ -268,11 +268,18 @@ bool wxFileDialog::Create(wxWindow *parent, const wxString& message, if ( !wildCard.empty() && !defaultFileName.empty() && !wxFileName(defaultFileName).HasExt() ) { - // append the default extension to the initial file name: GTK won't do - // it for us by default (unlike e.g. MSW) - const wxString defaultExt = m_fc.GetCurrentWildCard().AfterFirst('.'); - if ( defaultExt.find_first_of("?*") == wxString::npos ) - defaultFileNameWithExt += "." + defaultExt; + // append the default extension, if any, to the initial file name: GTK + // won't do it for us by default (unlike e.g. MSW) + const wxFileName fnWC(m_fc.GetCurrentWildCard()); + if ( fnWC.HasExt() ) + { + // Notice that we shouldn't append the extension if it's a wildcard + // because this is not useful: the user would need to change it to use + // some fixed extension anyhow. + const wxString& ext = fnWC.GetExt(); + if ( ext.find_first_of("?*") == wxString::npos ) + defaultFileNameWithExt << "." << ext; + } }