1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-21 16:11:11 +01:00

more progress on bug 113

better handling of error conditions in all BuildFromXML methods, per comment: 

// BuildFromXML methods should always return a BlockFile, not NULL,  
// even if the result is flawed (e.g., refers to nonexistent file), 
// as testing will be done in DirManager::ProjectFSCK().
This commit is contained in:
v.audacity
2010-07-30 03:04:37 +00:00
parent 874e530d84
commit 3729f067be
9 changed files with 139 additions and 188 deletions

View File

@@ -46,6 +46,9 @@ void SilentBlockFile::SaveXML(XMLWriter &xmlFile)
xmlFile.EndTag(wxT("silentblockfile"));
}
// BuildFromXML methods should always return a BlockFile, not NULL,
// even if the result is flawed (e.g., refers to nonexistent file),
// as testing will be done in DirManager::ProjectFSCK().
/// static
BlockFile *SilentBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
{
@@ -56,19 +59,17 @@ BlockFile *SilentBlockFile::BuildFromXML(DirManager &dm, const wxChar **attrs)
{
const wxChar *attr = *attrs++;
const wxChar *value = *attrs++;
if (!value)
break;
const wxString strValue = value;
if( !wxStrcmp(attr, wxT("len")) &&
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue))
len = nValue;
if (!wxStrcmp(attr, wxT("len")) &&
XMLValueChecker::IsGoodInt(strValue) &&
strValue.ToLong(&nValue) &&
len > 0)
len = nValue;
}
if (len <= 0)
return NULL;
return new SilentBlockFile(len);
}