Skip to content

Commit

Permalink
Merge ElucidataInc#1369 from saifulbkhan/fix_untargeted_memory_leak
Browse files Browse the repository at this point in the history
Fix - untargeted memory leak
  • Loading branch information
saifulbkhan authored Jan 8, 2021
2 parents e39a12c + 7255283 commit 5c0923e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
15 changes: 9 additions & 6 deletions src/core/libmaven/massslicer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,12 +428,15 @@ void MassSlicer::_reduceSlices(MassCutoff* massCutoff)
}

// remove merged slices
slices.erase(remove_if(slices.begin(),
slices.end(),
[](mzSlice* slice) {
return (slice->ionCount == -1.0f);
}),
slices.end());
vector<size_t> indexesToErase;
for (size_t i = 0; i < slices.size(); ++i) {
auto slice = slices[i];
if (slice->ionCount == -1.0f) {
delete slice;
indexesToErase.push_back(i);
}
}
mzUtils::eraseIndexes(slices, indexesToErase);
}

void MassSlicer::_mergeSlices(const MassCutoff* massCutoff,
Expand Down
3 changes: 2 additions & 1 deletion src/core/libmaven/peakdetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ void PeakDetector::processSlices(vector<mzSlice*>& slices,
return;

_mavenParameters->allgroups.insert(
_mavenParameters->allgroups.begin(),
_mavenParameters->allgroups.end(),
make_move_iterator(peakgroups.begin()),
make_move_iterator(peakgroups.end()));
};
Expand Down Expand Up @@ -1082,6 +1082,7 @@ void PeakDetector::detectIsotopesForParent(PeakGroup& parentGroup,
_mavenParameters,
_mavenParameters->clsf,
true);
delete_all(eics);
if (isotopeGroup->peakCount() == 0)
continue;

Expand Down
1 change: 1 addition & 0 deletions src/gui/mzroll/backgroundopsthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ void BackgroundOpsThread::updateGroups(QList<shared_ptr<PeakGroup>>& groups,
}
group->updateQuality();
group->groupStatistics();
delete_all(eics);
};

for(auto group : groups) {
Expand Down
12 changes: 8 additions & 4 deletions src/gui/mzroll/tabledockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2367,8 +2367,9 @@ PeakTableDockWidget::~PeakTableDockWidget() {
delete toolBar;
}

void PeakTableDockWidget::destroy() {

void PeakTableDockWidget::destroy()
{
TableDockWidget::deleteAll(false);
cleanUp();
deleteLater();
_mainwindow->removePeaksTable(this);
Expand All @@ -2377,8 +2378,11 @@ void PeakTableDockWidget::destroy() {
void PeakTableDockWidget::deleteAll()
{
auto allDeleted = TableDockWidget::deleteAll();
if (allDeleted)
destroy();
if (allDeleted) {
cleanUp();
deleteLater();
_mainwindow->removePeaksTable(this);
}
}

void PeakTableDockWidget::cleanUp()
Expand Down

0 comments on commit 5c0923e

Please sign in to comment.