Comment where xml writing functions may throw

This commit is contained in:
Paul Licameli 2016-12-01 17:03:40 -05:00
parent e3355c3c7e
commit b81cdee7e3
26 changed files with 44 additions and 2 deletions

View File

@ -72,6 +72,7 @@ WX_DECLARE_STRING_HASH_MAP_WITH_DECL(short, NameMap, class AUDACITY_DLL_API);
WX_DECLARE_HASH_MAP_WITH_DECL(short, wxString, wxIntegerHash, wxIntegerEqual, IdMap, class AUDACITY_DLL_API);
WX_DECLARE_OBJARRAY_WITH_DECL(IdMap, IdMapArray, class AUDACITY_DLL_API);
// This class's overrides do NOT throw AudacityException.
class AUDACITY_DLL_API AutoSaveFile final : public XMLWriter
{
public:

View File

@ -352,6 +352,7 @@ XMLTagHandler *Envelope::HandleXMLChild(const wxChar *tag)
}
void Envelope::WriteXML(XMLWriter &xmlFile) const
// may throw
{
unsigned int ctrlPt;

View File

@ -2266,6 +2266,7 @@ XMLTagHandler *LabelTrack::HandleXMLChild(const wxChar *tag)
}
void LabelTrack::WriteXML(XMLWriter &xmlFile) const
// may throw
{
int len = mLabels.size();

View File

@ -83,6 +83,7 @@ public:
};
static bool ConvertLegacyTrack(wxTextFile *f, XMLFileWriter &xmlFile)
// may throw
{
wxString line;
wxString kind;

View File

@ -804,6 +804,7 @@ XMLTagHandler *NoteTrack::HandleXMLChild(const wxChar * WXUNUSED(tag))
}
void NoteTrack::WriteXML(XMLWriter &xmlFile) const
// may throw
{
std::ostringstream data;
// Normally, Duplicate is called in pairs -- once to put NoteTrack

View File

@ -3541,6 +3541,7 @@ void AudacityProject::WriteXMLHeader(XMLWriter &xmlFile) const
}
void AudacityProject::WriteXML(XMLWriter &xmlFile)
// may throw
{
//TIMER_START( "AudacityProject::WriteXML", xml_writer_timer );
// Warning: This block of code is duplicated in Save, for now...

View File

@ -24,6 +24,7 @@ const wxChar *sDefaultF1Name = wxT("selHigh");
void SelectedRegion::WriteXMLAttributes
(XMLWriter &xmlFile,
const wxChar *legacyT0Name, const wxChar *legacyT1Name) const
// may throw
{
xmlFile.WriteAttr(legacyT0Name, t0(), 10);
xmlFile.WriteAttr(legacyT1Name, t1(), 10);

View File

@ -1026,6 +1026,7 @@ XMLTagHandler *Sequence::HandleXMLChild(const wxChar *tag)
// Throws exceptions rather than reporting errors.
void Sequence::WriteXML(XMLWriter &xmlFile) const
// may throw
{
unsigned int b;
@ -1544,8 +1545,9 @@ bool Sequence::Append(samplePtr buffer, sampleFormat format,
blockFileLog != NULL),
lastBlock.start
);
// FIXME: TRAP_ERR This could throw an exception that should(?) be converted to return false.
if (blockFileLog)
// shouldn't throw, because XMLWriter is not XMLFileWriter
static_cast< SimpleBlockFile * >( &*newLastBlock.f )
->SaveXML( *blockFileLog );
@ -1570,8 +1572,8 @@ bool Sequence::Append(samplePtr buffer, sampleFormat format,
blockFileLog != NULL);
}
// FIXME: TRAP_ERR This could throw an exception that should(?) be converted to return false.
if (blockFileLog)
// shouldn't throw, because XMLWriter is not XMLFileWriter
static_cast< SimpleBlockFile * >( &*pFile )->SaveXML( *blockFileLog );
mBlock.push_back(SeqBlock(pFile, mNumSamples));

View File

@ -551,6 +551,7 @@ XMLTagHandler *Tags::HandleXMLChild(const wxChar *tag)
}
void Tags::WriteXML(XMLWriter &xmlFile) const
// may throw
{
xmlFile.StartTag(wxT("tags"));

View File

@ -205,6 +205,7 @@ XMLTagHandler *TimeTrack::HandleXMLChild(const wxChar *tag)
}
void TimeTrack::WriteXML(XMLWriter &xmlFile) const
// may throw
{
xmlFile.StartTag(wxT("timetrack"));

View File

@ -162,6 +162,7 @@ void ViewInfo::SetBeforeScreenWidth(wxInt64 beforeWidth, wxInt64 screenWidth, do
}
void ViewInfo::WriteXMLAttributes(XMLWriter &xmlFile) const
// may throw
{
selectedRegion.WriteXMLAttributes(xmlFile, wxT("sel0"), wxT("sel1"));
xmlFile.WriteAttr(wxT("vpos"), vpos);

View File

@ -1515,6 +1515,7 @@ XMLTagHandler *WaveClip::HandleXMLChild(const wxChar *tag)
}
void WaveClip::WriteXML(XMLWriter &xmlFile) const
// may throw
{
xmlFile.StartTag(wxT("waveclip"));
xmlFile.WriteAttr(wxT("offset"), mOffset, 8);

View File

@ -1777,6 +1777,7 @@ XMLTagHandler *WaveTrack::HandleXMLChild(const wxChar *tag)
}
void WaveTrack::WriteXML(XMLWriter &xmlFile) const
// may throw
{
xmlFile.StartTag(wxT("wavetrack"));
if (mAutoSaveIdent)

View File

@ -62,6 +62,7 @@ BlockFilePtr LegacyAliasBlockFile::Copy(wxFileNameWrapper &&newFileName)
}
void LegacyAliasBlockFile::SaveXML(XMLWriter &xmlFile)
// may throw
{
xmlFile.StartTag(wxT("legacyblockfile"));

View File

@ -197,6 +197,7 @@ size_t LegacyBlockFile::ReadData(samplePtr data, sampleFormat format,
}
void LegacyBlockFile::SaveXML(XMLWriter &xmlFile)
// may throw
{
xmlFile.StartTag(wxT("legacyblockfile"));

View File

@ -191,6 +191,7 @@ BlockFilePtr ODDecodeBlockFile::Copy(wxFileNameWrapper &&newFileName)
/// Most notably, the summaryfile attribute refers to a file that does not yet, so when the project file is read back in
/// and this object reconstructed, it needs to avoid trying to open it as well as schedule itself for OD loading
void ODDecodeBlockFile::SaveXML(XMLWriter &xmlFile)
// may throw
{
LockRead();
if(IsSummaryAvailable())

View File

@ -227,6 +227,7 @@ BlockFilePtr ODPCMAliasBlockFile::Copy(wxFileNameWrapper &&newFileName)
/// Most notably, the summaryfile attribute refers to a file that does not yet exist, so when the project file is read back in
/// and this object reconstructed, it needs to avoid trying to open it as well as schedule itself for OD loading
void ODPCMAliasBlockFile::SaveXML(XMLWriter &xmlFile)
// may throw
{
//we lock this so that mAliasedFileName doesn't change.
LockRead();

View File

@ -101,6 +101,7 @@ BlockFilePtr PCMAliasBlockFile::Copy(wxFileNameWrapper &&newFileName)
}
void PCMAliasBlockFile::SaveXML(XMLWriter &xmlFile)
// may throw
{
xmlFile.StartTag(wxT("pcmaliasblockfile"));

View File

@ -39,6 +39,7 @@ size_t SilentBlockFile::ReadData(samplePtr data, sampleFormat format,
}
void SilentBlockFile::SaveXML(XMLWriter &xmlFile)
// may throw
{
xmlFile.StartTag(wxT("silentblockfile"));

View File

@ -404,6 +404,7 @@ size_t SimpleBlockFile::ReadData(samplePtr data, sampleFormat format,
}
void SimpleBlockFile::SaveXML(XMLWriter &xmlFile)
// may throw
{
xmlFile.StartTag(wxT("simpleblockfile"));

View File

@ -1434,6 +1434,7 @@ XMLTagHandler *CommandManager::HandleXMLChild(const wxChar * WXUNUSED(tag))
}
void CommandManager::WriteXML(XMLWriter &xmlFile) const
// may throw
{
xmlFile.StartTag(wxT("audacitykeyboard"));
xmlFile.WriteAttr(wxT("audacityversion"), AUDACITY_VERSION_STRING);

View File

@ -3579,6 +3579,7 @@ void EffectUIHost::OnImport(wxCommandEvent & WXUNUSED(evt))
void EffectUIHost::OnExport(wxCommandEvent & WXUNUSED(evt))
{
// may throw
mClient->ExportPresets();
return;

View File

@ -2044,6 +2044,7 @@ XMLTagHandler *EffectEqualization::HandleXMLChild(const wxChar *tag)
// Write all of the curves to the XML file
//
void EffectEqualization::WriteXML(XMLWriter &xmlFile) const
// may throw
{
// Start our heirarchy
xmlFile.StartTag( wxT( "equalizationeffect" ) );

View File

@ -1820,6 +1820,7 @@ void VSTEffect::ExportPresets()
}
else if (ext.CmpNoCase(wxT("xml")) == 0)
{
// may throw
SaveXML(fn);
}
else
@ -3559,6 +3560,7 @@ void VSTEffect::SaveFXProgram(wxMemoryBuffer & buf, int index)
// Throws exceptions rather than giving error return.
void VSTEffect::SaveXML(const wxFileName & fn)
// may throw
{
XMLFileWriter xmlFile;

View File

@ -828,6 +828,7 @@ XMLTagHandler *FFmpegPresets::HandleXMLChild(const wxChar *tag)
}
void FFmpegPresets::WriteXMLHeader(XMLWriter &xmlFile) const
// may throw
{
xmlFile.Write(wxT("<?xml "));
xmlFile.Write(wxT("version=\"1.0\" "));
@ -847,6 +848,7 @@ void FFmpegPresets::WriteXMLHeader(XMLWriter &xmlFile) const
}
void FFmpegPresets::WriteXML(XMLWriter &xmlFile) const
// may throw
{
xmlFile.StartTag(wxT("ffmpeg_presets"));
xmlFile.WriteAttr(wxT("version"),wxT("1.0"));

View File

@ -66,6 +66,7 @@ XMLWriter::~XMLWriter()
}
void XMLWriter::StartTag(const wxString &name)
// may throw
{
int i;
@ -88,6 +89,7 @@ void XMLWriter::StartTag(const wxString &name)
}
void XMLWriter::EndTag(const wxString &name)
// may throw
{
int i;
@ -117,6 +119,7 @@ void XMLWriter::EndTag(const wxString &name)
}
void XMLWriter::WriteAttr(const wxString &name, const wxString &value)
// may throw from Write()
{
Write(wxString::Format(wxT(" %s=\"%s\""),
name.c_str(),
@ -124,11 +127,13 @@ void XMLWriter::WriteAttr(const wxString &name, const wxString &value)
}
void XMLWriter::WriteAttr(const wxString &name, const wxChar *value)
// may throw from Write()
{
WriteAttr(name, wxString(value));
}
void XMLWriter::WriteAttr(const wxString &name, int value)
// may throw from Write()
{
Write(wxString::Format(wxT(" %s=\"%d\""),
name.c_str(),
@ -136,6 +141,7 @@ void XMLWriter::WriteAttr(const wxString &name, int value)
}
void XMLWriter::WriteAttr(const wxString &name, bool value)
// may throw from Write()
{
Write(wxString::Format(wxT(" %s=\"%d\""),
name.c_str(),
@ -143,6 +149,7 @@ void XMLWriter::WriteAttr(const wxString &name, bool value)
}
void XMLWriter::WriteAttr(const wxString &name, long value)
// may throw from Write()
{
Write(wxString::Format(wxT(" %s=\"%ld\""),
name.c_str(),
@ -150,6 +157,7 @@ void XMLWriter::WriteAttr(const wxString &name, long value)
}
void XMLWriter::WriteAttr(const wxString &name, long long value)
// may throw from Write()
{
Write(wxString::Format(wxT(" %s=\"%lld\""),
name.c_str(),
@ -157,6 +165,7 @@ void XMLWriter::WriteAttr(const wxString &name, long long value)
}
void XMLWriter::WriteAttr(const wxString &name, size_t value)
// may throw from Write()
{
Write(wxString::Format(wxT(" %s=\"%lld\""),
name.c_str(),
@ -164,6 +173,7 @@ void XMLWriter::WriteAttr(const wxString &name, size_t value)
}
void XMLWriter::WriteAttr(const wxString &name, float value, int digits)
// may throw from Write()
{
Write(wxString::Format(wxT(" %s=\"%s\""),
name.c_str(),
@ -171,6 +181,7 @@ void XMLWriter::WriteAttr(const wxString &name, float value, int digits)
}
void XMLWriter::WriteAttr(const wxString &name, double value, int digits)
// may throw from Write()
{
Write(wxString::Format(wxT(" %s=\"%s\""),
name.c_str(),
@ -178,6 +189,7 @@ void XMLWriter::WriteAttr(const wxString &name, double value, int digits)
}
void XMLWriter::WriteData(const wxString &value)
// may throw from Write()
{
int i;
@ -189,6 +201,7 @@ void XMLWriter::WriteData(const wxString &value)
}
void XMLWriter::WriteSubTree(const wxString &value)
// may throw from Write()
{
if (mInTag) {
Write(wxT(">\n"));
@ -270,6 +283,7 @@ void XMLFileWriter::Open(const wxString &name, const wxString &mode)
}
void XMLFileWriter::Close()
// may throw
{
while (mTagstack.GetCount()) {
EndTag(mTagstack[0]);