1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-01-02 14:17:07 +01:00

Exception safety in: BatchCommands

This commit is contained in:
Paul Licameli
2017-03-15 15:29:35 -04:00
parent 1a90b7d942
commit 195732f074

View File

@@ -481,10 +481,14 @@ bool BatchCommands::WriteMp3File( const wxString & Name, int bitrate )
bool rc; bool rc;
long prevBitRate = gPrefs->Read(wxT("/FileFormats/MP3Bitrate"), 128); long prevBitRate = gPrefs->Read(wxT("/FileFormats/MP3Bitrate"), 128);
gPrefs->Write(wxT("/FileFormats/MP3Bitrate"), bitrate); gPrefs->Write(wxT("/FileFormats/MP3Bitrate"), bitrate);
auto cleanup = finally( [&] {
gPrefs->Write(wxT("/FileFormats/MP3Bitrate"), prevBitRate);
gPrefs->Flush();
} );
// Use Mp3Stereo to control if export is to a stereo or mono file // Use Mp3Stereo to control if export is to a stereo or mono file
rc = mExporter.Process(project, numChannels, wxT("MP3"), Name, false, 0.0, endTime); rc = mExporter.Process(project, numChannels, wxT("MP3"), Name, false, 0.0, endTime);
gPrefs->Write(wxT("/FileFormats/MP3Bitrate"), prevBitRate);
gPrefs->Flush();
return rc; return rc;
} }