From 297befc6f825a13130e041cebd284a8815efd9e0 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 21 May 2022 21:13:32 +0200 Subject: [PATCH] undo: pass divecomputer number to EditSensors command Don't access the global variable dc_number, which might not make sense on mobile. Signed-off-by: Berthold Stoeger --- commands/command.cpp | 4 ++-- commands/command.h | 2 +- commands/command_edit.cpp | 4 ++-- commands/command_edit.h | 2 +- qt-models/cylindermodel.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/commands/command.cpp b/commands/command.cpp index 9577c08c0..a22022f31 100644 --- a/commands/command.cpp +++ b/commands/command.cpp @@ -312,9 +312,9 @@ int editCylinder(int index, cylinder_t cyl, EditCylinderType type, bool currentD return execute_edit(new EditCylinder(index, cyl, type, currentDiveOnly)); } -void editSensors(int toCylinder, const int fromCylinder) +void editSensors(int toCylinder, int fromCylinder, int dcNr) { - execute(new EditSensors(toCylinder, fromCylinder)); + execute(new EditSensors(toCylinder, fromCylinder, dcNr)); } // Trip editing related commands diff --git a/commands/command.h b/commands/command.h index 9a4eb0af2..3342f9542 100644 --- a/commands/command.h +++ b/commands/command.h @@ -114,7 +114,7 @@ enum class EditCylinderType { GASMIX }; int editCylinder(int index, cylinder_t cyl, EditCylinderType type, bool currentDiveOnly); -void editSensors(int toCylinder, const int fromCylinder); +void editSensors(int toCylinder, int fromCylinder, int dcNr); #ifdef SUBSURFACE_MOBILE // Edits a dive and creates a divesite (if createDs != NULL) or edits a divesite (if changeDs != NULL). // Takes ownership of newDive and createDs! diff --git a/commands/command_edit.cpp b/commands/command_edit.cpp index 881607830..6e198fb44 100644 --- a/commands/command_edit.cpp +++ b/commands/command_edit.cpp @@ -1351,8 +1351,8 @@ void EditCylinder::undo() redo(); } -EditSensors::EditSensors(int toCylinderIn, int fromCylinderIn) - : d(current_dive), dc(get_dive_dc(d, dc_number)), toCylinder(toCylinderIn), fromCylinder(fromCylinderIn) +EditSensors::EditSensors(int toCylinderIn, int fromCylinderIn, int dcNr) + : d(current_dive), dc(get_dive_dc(d, dcNr)), toCylinder(toCylinderIn), fromCylinder(fromCylinderIn) { if (!d || !dc) return; diff --git a/commands/command_edit.h b/commands/command_edit.h index c6e391079..417e994a0 100644 --- a/commands/command_edit.h +++ b/commands/command_edit.h @@ -444,7 +444,7 @@ private: class EditSensors : public Base { public: - EditSensors(int cylIndex, int fromCylinder); + EditSensors(int cylIndex, int fromCylinder, int dcNr); private: struct dive *d; diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp index 157352e9e..4810e2dc1 100644 --- a/qt-models/cylindermodel.cpp +++ b/qt-models/cylindermodel.cpp @@ -475,7 +475,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in bool ok = false; int s = vString.toInt(&ok); if (ok) { - Command::editSensors(index.row(), s); + Command::editSensors(index.row(), s, dc_number); // We don't use the edit cylinder command and editing sensors is not relevant for planner return true; }