diff --git a/desktop-widgets/modeldelegates.cpp b/desktop-widgets/modeldelegates.cpp index e432448dc..ccda7c9b4 100644 --- a/desktop-widgets/modeldelegates.cpp +++ b/desktop-widgets/modeldelegates.cpp @@ -371,8 +371,8 @@ void AirTypesDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, } AirTypesDelegate::AirTypesDelegate(const dive &d, QObject *parent) : - ComboBoxDelegate([d] (QWidget *parent) { return new GasSelectionModel(d, parent); }, - parent, false) + ComboBoxDelegate([&d] (QWidget *parent) { return new GasSelectionModel(d, parent); }, + parent, false) { } diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index 6868e2bea..ce6972744 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -614,9 +614,8 @@ void CylindersModel::updateNumRows() // Only invoked from planner. void CylindersModel::moveAtFirst(int cylid) { - if (!d) + if (!d || cylid <= 0 || cylid >= d->cylinders.nr) return; - cylinder_t temp_cyl; beginMoveRows(QModelIndex(), cylid, cylid, QModelIndex(), 0); diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index b065138f6..36a72ecf7 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -381,7 +381,7 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v if (value.toInt() >= 0) p.cylinderid = value.toInt(); /* Did we change the start (dp 0) cylinder to another cylinderid than 0? */ - if (value.toInt() != 0 && index.row() == 0) + if (value.toInt() > 0 && index.row() == 0) cylinders.moveAtFirst(value.toInt()); cylinders.updateTrashIcon(); break;