1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-20 06:10:06 +02:00

Bug834, part 1 - Memory leak and orphans after cancelling any generator

This fixes the first of two related memory leak bugs:

New project.  Make a new track.  Select the track and use any generator, such
as white noise, specifying a long enough length that a progress dialog appears.
Cancel the progress dialog.

Save the project.  Exit and restart Audacity.  Reopen the project.

Orphans!
This commit is contained in:
Paul-Licameli 2015-04-08 11:22:57 -04:00
parent 5b4b3e3c53
commit a562f2c922

View File

@ -59,21 +59,22 @@ bool Generator::Process()
if (mDuration > 0.0)
{
// Create a temporary track
WaveTrack *tmp = mFactory->NewWaveTrack(track->GetSampleFormat(),
track->GetRate());
std::auto_ptr<WaveTrack> tmp(
mFactory->NewWaveTrack(track->GetSampleFormat(),
track->GetRate())
);
BeforeTrack(*track);
BeforeGenerate();
// Fill it with data
if (!GenerateTrack(tmp, *track, ntrack))
if (!GenerateTrack(&*tmp, *track, ntrack))
bGoodResult = false;
else {
// Transfer the data from the temporary track to the actual one
tmp->Flush();
SetTimeWarper(new StepTimeWarper(mT0+mDuration, mDuration-(mT1-mT0)));
bGoodResult = track->ClearAndPaste(mT0, mT1, tmp, true,
bGoodResult = track->ClearAndPaste(mT0, mT1, &*tmp, true,
false, GetTimeWarper());
delete tmp;
}
if (!bGoodResult) {