mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Fix a couple of small problems in add weightsystem
The constructor letf the currentWeightsytem variable uninitialized. Instead of creating the memory leak by malloc-ing the newWeightsystem in the on_addWeight_clicked() function use a local variable instead and pass its address around. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
f45618f0c7
commit
00d8531382
2 changed files with 6 additions and 5 deletions
|
@ -14,6 +14,7 @@
|
|||
AddWeightsystemDialog::AddWeightsystemDialog(QWidget *parent) : ui(new Ui::AddWeightsystemDialog())
|
||||
{
|
||||
ui->setupUi(this);
|
||||
currentWeightsystem = NULL;
|
||||
}
|
||||
|
||||
void AddWeightsystemDialog::setWeightsystem(weightsystem_t *ws)
|
||||
|
|
|
@ -93,17 +93,17 @@ void MainTab::on_addWeight_clicked()
|
|||
return;
|
||||
|
||||
AddWeightsystemDialog dialog(this);
|
||||
weightsystem_t *newWeightsystem = (weightsystem_t *) malloc(sizeof(weightsystem_t));
|
||||
newWeightsystem->description = "";
|
||||
newWeightsystem->weight.grams = 0;
|
||||
weightsystem_t newWeightsystem;
|
||||
newWeightsystem.description = "";
|
||||
newWeightsystem.weight.grams = 0;
|
||||
|
||||
dialog.setWeightsystem(newWeightsystem);
|
||||
dialog.setWeightsystem(&newWeightsystem);
|
||||
int result = dialog.exec();
|
||||
if (result == QDialog::Rejected)
|
||||
return;
|
||||
|
||||
dialog.updateWeightsystem();
|
||||
weightModel->add(newWeightsystem);
|
||||
weightModel->add(&newWeightsystem);
|
||||
}
|
||||
|
||||
void MainTab::on_editWeight_clicked()
|
||||
|
|
Loading…
Reference in a new issue