mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
Don't leak memory on downloaded dives not picked
I noticed this in the mobile download code when fixing an unrelated issue - and then realized that the same was true in the desktop app as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
76a38b6326
commit
57d01701aa
2 changed files with 12 additions and 3 deletions
|
@ -421,6 +421,8 @@ void DownloadFromDCWidget::on_ok_clicked()
|
|||
for (int i = 0; i < downloadTable.nr; i++) {
|
||||
if (diveImportedModel->data(diveImportedModel->index(i, 0),Qt::CheckStateRole) == Qt::Checked)
|
||||
record_dive(downloadTable.dives[i]);
|
||||
else
|
||||
clear_dive(downloadTable.dives[i]);
|
||||
downloadTable.dives[i] = NULL;
|
||||
}
|
||||
downloadTable.nr = 0;
|
||||
|
|
|
@ -148,11 +148,18 @@ void DiveImportedModel::repopulate()
|
|||
|
||||
void DiveImportedModel::recordDives()
|
||||
{
|
||||
// walk the table of imported dives and record the ones that the user picked
|
||||
// clearing out the table as we go
|
||||
for (int i = 0; i < rowCount(); i++) {
|
||||
if (diveTable->dives[i] && checkStates[i]) {
|
||||
record_dive(diveTable->dives[i]);
|
||||
diveTable->dives[i] = NULL;
|
||||
struct dive *d = diveTable->dives[i];
|
||||
if (d && checkStates[i]) {
|
||||
record_dive(d);
|
||||
} else {
|
||||
// we should free the dives that weren't recorded
|
||||
clear_dive(d);
|
||||
free(d)
|
||||
}
|
||||
diveTable->dives[i] = NULL;
|
||||
}
|
||||
diveTable->nr = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue