mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-10 17:11:17 +02:00
Change handling of added tracks in ImportAup...
... Add them to the project, not a temporary array; revoke the addition if there is a failure. Preliminary for fixing bug 2570.
This commit is contained in:
parent
8ac1cb75aa
commit
e9d72ed6df
@ -206,7 +206,6 @@ private:
|
|||||||
std::map<wxString, std::pair<FilePath, std::shared_ptr<SampleBlock>>>;
|
std::map<wxString, std::pair<FilePath, std::shared_ptr<SampleBlock>>>;
|
||||||
BlockFileMap mFileMap;
|
BlockFileMap mFileMap;
|
||||||
|
|
||||||
ListOfTracks mTracks;
|
|
||||||
WaveTrack *mWaveTrack;
|
WaveTrack *mWaveTrack;
|
||||||
WaveClip *mClip;
|
WaveClip *mClip;
|
||||||
|
|
||||||
@ -284,7 +283,16 @@ ProgressResult AUPImportFileHandle::Import(WaveTrackFactory *WXUNUSED(trackFacto
|
|||||||
auto &settings = ProjectSettings::Get(mProject);
|
auto &settings = ProjectSettings::Get(mProject);
|
||||||
auto &selman = ProjectSelectionManager::Get(mProject);
|
auto &selman = ProjectSelectionManager::Get(mProject);
|
||||||
|
|
||||||
auto cleanup = finally([this]{ mTracks.clear(); });
|
auto oldNumTracks = tracks.size();
|
||||||
|
auto cleanup = finally([this, &tracks, oldNumTracks]{
|
||||||
|
if (mUpdateResult != ProgressResult::Success) {
|
||||||
|
// Revoke additions of tracks
|
||||||
|
while (oldNumTracks < tracks.size()) {
|
||||||
|
Track *lastTrack = *tracks.Any().rbegin();
|
||||||
|
tracks.Remove(lastTrack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
bool isDirty = history.GetDirty() || !tracks.empty();
|
bool isDirty = history.GetDirty() || !tracks.empty();
|
||||||
|
|
||||||
@ -352,12 +360,8 @@ ProgressResult AUPImportFileHandle::Import(WaveTrackFactory *WXUNUSED(trackFacto
|
|||||||
|
|
||||||
processed += fi.len;
|
processed += fi.len;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the tracks we just created into the project.
|
wxASSERT( mUpdateResult == ProgressResult::Success );
|
||||||
for (auto &track : mTracks)
|
|
||||||
{
|
|
||||||
tracks.Add(track);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the active project is "dirty", then bypass the below updates as we don't
|
// If the active project is "dirty", then bypass the below updates as we don't
|
||||||
// want to going changing things the user may have already set up.
|
// want to going changing things the user may have already set up.
|
||||||
@ -828,9 +832,7 @@ bool AUPImportFileHandle::HandleProject(XMLTagHandler *&handler)
|
|||||||
|
|
||||||
bool AUPImportFileHandle::HandleLabelTrack(XMLTagHandler *&handler)
|
bool AUPImportFileHandle::HandleLabelTrack(XMLTagHandler *&handler)
|
||||||
{
|
{
|
||||||
mTracks.push_back(std::make_shared<LabelTrack>());
|
handler = TrackList::Get(mProject).Add(std::make_shared<LabelTrack>());
|
||||||
|
|
||||||
handler = mTracks.back().get();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -838,9 +840,7 @@ bool AUPImportFileHandle::HandleLabelTrack(XMLTagHandler *&handler)
|
|||||||
bool AUPImportFileHandle::HandleNoteTrack(XMLTagHandler *&handler)
|
bool AUPImportFileHandle::HandleNoteTrack(XMLTagHandler *&handler)
|
||||||
{
|
{
|
||||||
#if defined(USE_MIDI)
|
#if defined(USE_MIDI)
|
||||||
mTracks.push_back( std::make_shared<NoteTrack>());
|
handler = TrackList::Get(mProject).Add(std::make_shared<NoteTrack>());
|
||||||
|
|
||||||
handler = mTracks.back().get();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
#else
|
#else
|
||||||
@ -872,9 +872,8 @@ bool AUPImportFileHandle::HandleTimeTrack(XMLTagHandler *&handler)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto &viewInfo = ViewInfo::Get( mProject );
|
auto &viewInfo = ViewInfo::Get( mProject );
|
||||||
mTracks.push_back( std::make_shared<TimeTrack>(&viewInfo) );
|
handler =
|
||||||
|
TrackList::Get(mProject).Add(std::make_shared<TimeTrack>(&viewInfo));
|
||||||
handler = mTracks.back().get();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -882,11 +881,8 @@ bool AUPImportFileHandle::HandleTimeTrack(XMLTagHandler *&handler)
|
|||||||
bool AUPImportFileHandle::HandleWaveTrack(XMLTagHandler *&handler)
|
bool AUPImportFileHandle::HandleWaveTrack(XMLTagHandler *&handler)
|
||||||
{
|
{
|
||||||
auto &trackFactory = WaveTrackFactory::Get(mProject);
|
auto &trackFactory = WaveTrackFactory::Get(mProject);
|
||||||
mTracks.push_back(trackFactory.NewWaveTrack());
|
handler = mWaveTrack =
|
||||||
|
TrackList::Get(mProject).Add(trackFactory.NewWaveTrack());
|
||||||
handler = mTracks.back().get();
|
|
||||||
|
|
||||||
mWaveTrack = static_cast<WaveTrack *>(handler);
|
|
||||||
|
|
||||||
// No active clip. In early versions of Audacity, there was a single
|
// No active clip. In early versions of Audacity, there was a single
|
||||||
// implied clip so we'll create a clip when the first "sequence" is
|
// implied clip so we'll create a clip when the first "sequence" is
|
||||||
|
Loading…
x
Reference in New Issue
Block a user