From 2cfb35b6d7b5bb7bb7275f078bf2aff959e6ecef Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 3 Nov 2019 15:25:23 +0100 Subject: Cleanup: return value type from WeightModel::weightSystemAt() There is only one caller of WeightModel::weightSystemAt() and that certainly does not need a pointer into the weightsystem-table of the current dive. Return a value type instead of a pointer. This allows us to mark WeightModel::weightSystemAt() as const and use it from WeightModel::data(). Slightly cleaner code. Signed-off-by: Berthold Stoeger --- qt-models/weightmodel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'qt-models/weightmodel.cpp') diff --git a/qt-models/weightmodel.cpp b/qt-models/weightmodel.cpp index ff0b5c87a..4a931a4bb 100644 --- a/qt-models/weightmodel.cpp +++ b/qt-models/weightmodel.cpp @@ -19,14 +19,14 @@ WeightModel::WeightModel(QObject *parent) : CleanerTableModel(parent), connect(&diveListNotifier, &DiveListNotifier::weightRemoved, this, &WeightModel::weightRemoved); } -weightsystem_t *WeightModel::weightSystemAt(const QModelIndex &index) +weightsystem_t WeightModel::weightSystemAt(const QModelIndex &index) { int row = index.row(); if (row < 0 || row >= d->weightsystems.nr) { qWarning("WeightModel: Accessing invalid weightsystem %d (of %d)", row, d->weightsystems.nr); - return nullptr; + return { { 0 }, nullptr }; } - return &d->weightsystems.weightsystems[index.row()]; + return d->weightsystems.weightsystems[index.row()]; } void WeightModel::clear() -- cgit v1.2.3-70-g09d2