From 53a8b44f1df77baec98fa66fae658c56f628dabc Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 26 Jan 2016 13:48:37 -0500 Subject: [PATCH 1/2] Bug1217: Export "other uncompressed files" now uses correct default extension... ... but there is this consequence: If you do type an explicit extension, which is one of the acceptable extensions though different from the "Header:" chocie, then it is also corrected, silently. This behavior is different from other cases where the user types an inappropriate explicit extension and is prompted to fix it. --- src/export/Export.cpp | 2 +- src/export/Export.h | 2 +- src/export/ExportPCM.cpp | 24 +++++++++++++++++++++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/export/Export.cpp b/src/export/Export.cpp index 7ef520daf..5b7925b50 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -185,7 +185,7 @@ wxString ExportPlugin::GetMask(int index) wxString mask = GetDescription(index) + wxT("|"); // Build the mask - wxString ext = GetExtension(index); + // wxString ext = GetExtension(index); wxArrayString exts = GetExtensions(index); for (size_t i = 0; i < exts.GetCount(); i++) { mask += wxT("*.") + exts[i] + wxT(";"); diff --git a/src/export/Export.h b/src/export/Export.h index e227f2df4..a95cbf9d8 100644 --- a/src/export/Export.h +++ b/src/export/Export.h @@ -38,7 +38,7 @@ class AUDACITY_DLL_API FormatInfo ~FormatInfo(){}; wxString mFormat; wxString mDescription; - wxString mExtension; + // wxString mExtension; wxArrayString mExtensions; wxString mMask; int mMaxChannels; diff --git a/src/export/ExportPCM.cpp b/src/export/ExportPCM.cpp index 876d18f7f..b8a648e19 100644 --- a/src/export/ExportPCM.cpp +++ b/src/export/ExportPCM.cpp @@ -168,6 +168,7 @@ ExportPCMOptions::ExportPCMOptions(wxWindow *parent, int selformat) PopulateOrExchange(S); TransferDataToWindow(); + TransferDataFromWindow(); } ExportPCMOptions::~ExportPCMOptions() @@ -268,6 +269,8 @@ void ExportPCMOptions::OnHeaderChoice(wxCommandEvent & WXUNUSED(evt)) mEncodingFromChoice = sel; mEncodingChoice->SetSelection(sel); ValidatePair(GetFormat()); + + TransferDataFromWindow(); } int ExportPCMOptions::GetFormat() @@ -320,7 +323,8 @@ public: Tags *metadata = NULL, int subformat = 0); // optional - wxString GetExtension(int index = WXSIZEOF(kFormats)); + wxString GetExtension(int index); + virtual bool CheckFileName(wxFileName &filename, int format); private: @@ -894,6 +898,24 @@ wxString ExportPCM::GetExtension(int index) } } +bool ExportPCM::CheckFileName(wxFileName &filename, int format) +{ + if (format == WXSIZEOF(kFormats) && + IsExtension(filename.GetExt(), format)) { + // PRL: Bug1217 + // If the user left the extension blank, then the + // file dialog will have defaulted the extension, beyond our control, + // to the first in the wildcard list or (Linux) the last-saved extension, + // ignoring what we try to do with the additional drop-down mHeaderChoice. + // Here we can intercept file name processing and impose the correct default. + // However this has the consequence that in case an explicit extension was typed, + // we override it without asking. + filename.SetExt(GetExtension(format)); + } + + return ExportPlugin::CheckFileName(filename, format); +} + ExportPlugin *New_ExportPCM() { return new ExportPCM(); From a047fcf0f82e37c0a10f5b5b7c332eb2b3417660 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Tue, 26 Jan 2016 14:14:10 -0500 Subject: [PATCH 2/2] Travis --- src/export/Export.cpp | 2 +- src/export/Export.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/export/Export.cpp b/src/export/Export.cpp index 5b7925b50..9d481b3ca 100644 --- a/src/export/Export.cpp +++ b/src/export/Export.cpp @@ -204,7 +204,7 @@ bool ExportPlugin::GetCanMetaData(int index) return mFormatInfos[index].mCanMetaData; } -bool ExportPlugin::IsExtension(wxString & ext, int index) +bool ExportPlugin::IsExtension(const wxString & ext, int index) { bool isext = false; for (int i = index; i < GetFormatCount(); i = GetFormatCount()) diff --git a/src/export/Export.h b/src/export/Export.h index a95cbf9d8..65ea85f7d 100644 --- a/src/export/Export.h +++ b/src/export/Export.h @@ -80,7 +80,7 @@ public: virtual int GetMaxChannels(int index); virtual bool GetCanMetaData(int index); - virtual bool IsExtension(wxString & ext, int index); + virtual bool IsExtension(const wxString & ext, int index); virtual bool DisplayOptions(wxWindow *parent, int format = 0);