1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-26 07:13:49 +01:00

Added consistency checks for Sequence, hoisted out of inner loops.

This commit is contained in:
Paul Licameli
2016-02-03 12:56:21 -05:00
parent 7be911b7fb
commit 13f7d0a81b
3 changed files with 56 additions and 18 deletions

View File

@@ -283,6 +283,28 @@ RecordingRecoveryHandler::RecordingRecoveryHandler(AudacityProject* proj)
mNumChannels = -1;
}
int RecordingRecoveryHandler::FindTrack() const
{
WaveTrackArray tracks = mProject->GetTracks()->GetWaveTrackArray(false);
int index;
if (mAutoSaveIdent)
{
for (index = 0; index < (int)tracks.GetCount(); index++)
{
if (tracks[index]->GetAutoSaveIdent() == mAutoSaveIdent)
{
break;
}
}
}
else
{
index = tracks.GetCount() - mNumChannels + mChannel;
}
return index;
}
bool RecordingRecoveryHandler::HandleXMLTag(const wxChar *tag,
const wxChar **attrs)
{
@@ -296,23 +318,9 @@ bool RecordingRecoveryHandler::HandleXMLTag(const wxChar *tag,
return false;
}
// We need to find the track and sequence where the blockfile belongs
WaveTrackArray tracks = mProject->GetTracks()->GetWaveTrackArray(false);
int index;
if (mAutoSaveIdent)
{
for (index = 0; index < (int) tracks.GetCount(); index++)
{
if (tracks[index]->GetAutoSaveIdent() == mAutoSaveIdent)
{
break;
}
}
}
else
{
index = tracks.GetCount() - mNumChannels + mChannel;
}
int index = FindTrack();
// We need to find the track and sequence where the blockfile belongs
if (index < 0 || index >= (int) tracks.GetCount())
{
@@ -391,6 +399,29 @@ bool RecordingRecoveryHandler::HandleXMLTag(const wxChar *tag,
return true;
}
void RecordingRecoveryHandler::HandleXMLEndTag(const wxChar *tag)
{
if (wxStrcmp(tag, wxT("simpleblockfile")) == 0)
// Still in inner looop
return;
WaveTrackArray tracks = mProject->GetTracks()->GetWaveTrackArray(false);
int index = FindTrack();
// We need to find the track and sequence where the blockfile belongs
if (index < 0 || index >= (int)tracks.GetCount()) {
// This should only happen if there is a bug
wxASSERT(false);
}
else {
WaveTrack* track = tracks.Item(index);
WaveClip* clip = track->NewestOrNewClip();
Sequence* seq = clip->GetSequence();
seq->ConsistencyCheck(wxT("RecordingRecoveryHandler::HandleXMLEndTag"));
}
}
XMLTagHandler* RecordingRecoveryHandler::HandleXMLChild(const wxChar *tag)
{
if (wxStrcmp(tag, wxT("simpleblockfile")) == 0)