Cylinders: Fix crash when removing cylinders

Change the remove() function of the cylinder and weight models
to take the index by value. The code used to take it by reference
and the reference would be invalidated when removing rows from
the model!

Reported-by: Gaetan Bisson <bisson@archlinux.org>
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-11-26 23:41:56 +01:00 committed by Dirk Hohndel
parent 7eda75d7ab
commit ddfc384b61
4 changed files with 4 additions and 4 deletions

View file

@ -486,7 +486,7 @@ Qt::ItemFlags CylindersModel::flags(const QModelIndex &index) const
return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
}
void CylindersModel::remove(const QModelIndex &index)
void CylindersModel::remove(QModelIndex index)
{
if (index.column() == USE) {

View file

@ -46,7 +46,7 @@ public:
public
slots:
void remove(const QModelIndex &index);
void remove(QModelIndex index);
void cylindersReset(const QVector<dive *> &dives);
bool updateBestMixes();

View file

@ -21,7 +21,7 @@ weightsystem_t *WeightModel::weightSystemAt(const QModelIndex &index)
return &displayed_dive.weightsystems.weightsystems[index.row()];
}
void WeightModel::remove(const QModelIndex &index)
void WeightModel::remove(QModelIndex index)
{
if (index.column() != REMOVE)
return;

View file

@ -31,7 +31,7 @@ public:
public
slots:
void remove(const QModelIndex &index);
void remove(QModelIndex index);
void weightsystemsReset(const QVector<dive *> &dives);
private: