Fix memory leaks within tests (#7001)
Caused by not calling `Engine::destroy`, as well as creating tracks/clips on the heap and not freeing the memory at the end of the test. Instead of creating tracks/clips on the heap, they are now made on the stack, similar to how the surrounding tests create its objects.
This commit is contained in:
@@ -19,5 +19,6 @@ int main(int argc, char* argv[])
|
||||
if (QTest::qExec(suite, argc, argv) != 0) { ++failed; }
|
||||
}
|
||||
qDebug() << "<<" << failed << "out of"<<numsuites<<"test suites failed.";
|
||||
lmms::Engine::destroy();
|
||||
return failed;
|
||||
}
|
||||
|
||||
@@ -148,12 +148,11 @@ private slots:
|
||||
|
||||
auto song = Engine::getSong();
|
||||
|
||||
InstrumentTrack* instrumentTrack =
|
||||
dynamic_cast<InstrumentTrack*>(Track::create(Track::Type::Instrument, song));
|
||||
InstrumentTrack instrumentTrack(song);
|
||||
|
||||
MidiClip* midiClip = dynamic_cast<MidiClip*>(instrumentTrack->createClip(0));
|
||||
midiClip->changeLength(TimePos(4, 0));
|
||||
Note* note = midiClip->addNote(Note(TimePos(4, 0)), false);
|
||||
MidiClip midiClip(&instrumentTrack);
|
||||
midiClip.changeLength(TimePos(4, 0));
|
||||
Note* note = midiClip.addNote(Note(TimePos(4, 0)), false);
|
||||
note->createDetuning();
|
||||
|
||||
DetuningHelper* dh = note->detuning();
|
||||
@@ -175,10 +174,11 @@ private slots:
|
||||
auto song = Engine::getSong();
|
||||
auto patternStore = Engine::patternStore();
|
||||
PatternTrack patternTrack(song);
|
||||
Track* automationTrack = Track::create(Track::Type::Automation, patternStore);
|
||||
AutomationTrack automationTrack(patternStore);
|
||||
automationTrack.createClipsForPattern(patternStore->numOfPatterns() - 1);
|
||||
|
||||
QVERIFY(automationTrack->numOfClips());
|
||||
AutomationClip* c1 = dynamic_cast<AutomationClip*>(automationTrack->getClip(0));
|
||||
QVERIFY(automationTrack.numOfClips());
|
||||
auto c1 = dynamic_cast<AutomationClip*>(automationTrack.getClip(0));
|
||||
QVERIFY(c1);
|
||||
|
||||
FloatModel model;
|
||||
|
||||
Reference in New Issue
Block a user