diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-11-26 23:41:56 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-11-26 17:21:34 -0800 |
commit | ddfc384b61b5990a54a5b0613a39c3ffb4ac23f4 (patch) | |
tree | fce5ed9de3c5a76e8e5671c81cda724bce504f4f /qt-models | |
parent | 7eda75d7abb0c0b42e8d71bcfcb4bc09c22ce300 (diff) | |
download | subsurface-ddfc384b61b5990a54a5b0613a39c3ffb4ac23f4.tar.gz |
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>
Diffstat (limited to 'qt-models')
-rw-r--r-- | qt-models/cylindermodel.cpp | 2 | ||||
-rw-r--r-- | qt-models/cylindermodel.h | 2 | ||||
-rw-r--r-- | qt-models/weightmodel.cpp | 2 | ||||
-rw-r--r-- | qt-models/weightmodel.h | 2 |
4 files changed, 4 insertions, 4 deletions
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index 22fc5ae8b..5d697470f 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -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) { diff --git a/qt-models/cylindermodel.h b/qt-models/cylindermodel.h index 0def53ba9..1596fa87f 100644 --- a/qt-models/cylindermodel.h +++ b/qt-models/cylindermodel.h @@ -46,7 +46,7 @@ public: public slots: - void remove(const QModelIndex &index); + void remove(QModelIndex index); void cylindersReset(const QVector<dive *> &dives); bool updateBestMixes(); diff --git a/qt-models/weightmodel.cpp b/qt-models/weightmodel.cpp index 3b5a122bf..36971f12e 100644 --- a/qt-models/weightmodel.cpp +++ b/qt-models/weightmodel.cpp @@ -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; diff --git a/qt-models/weightmodel.h b/qt-models/weightmodel.h index 2f59daf4b..21737a42c 100644 --- a/qt-models/weightmodel.h +++ b/qt-models/weightmodel.h @@ -31,7 +31,7 @@ public: public slots: - void remove(const QModelIndex &index); + void remove(QModelIndex index); void weightsystemsReset(const QVector<dive *> &dives); private: |