From 217c82f6c4207a5afe086d15edb29db59e523575 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 6 May 2014 09:58:27 -0700 Subject: Change EDIT_SELECTED_DIVES macro The way this is implemented is broken in several ways. This fixes the first issue. For the invocations where we are in the 'WHAT' checking to see if the value we are changing in the selected dive was previously the same as in the current dive (which is the one shown to the user for editing), then we need to make sure we change the current dive last, otherwise the comparison will fail. Of course, right now we only do this check for gps location, which is a massive bug as far as I am concerned. Fixes #515 Signed-off-by: Dirk Hohndel --- qt-ui/maintab.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'qt-ui/maintab.cpp') diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 28c497815..68960897d 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -836,20 +836,27 @@ void MainTab::rejectChanges() } #undef EDIT_TEXT2 +// tricky little macro to edit all the selected dives +// loop over all dives, for each selected dive do WHAT, but do it +// last for the current dive; this is required in case the invocation +// wants to compare things to the original value in current_dive like it should #define EDIT_SELECTED_DIVES(WHAT) \ do { \ + struct dive *mydive = NULL; \ if (editMode == NONE) \ return; \ - \ + \ for (int _i = 0; _i < dive_table.nr; _i++) { \ - struct dive *mydive = get_dive(_i); \ - if (!mydive) \ + mydive = get_dive(_i); \ + if (!mydive || mydive == current_dive)\ continue; \ if (!mydive->selected) \ continue; \ - \ + \ WHAT; \ } \ + mydive = current_dive; \ + WHAT; \ } while (0) void markChangedWidget(QWidget *w) -- cgit v1.2.3-70-g09d2