summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-06 09:58:27 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-05-06 09:58:27 -0700
commit217c82f6c4207a5afe086d15edb29db59e523575 (patch)
tree121243b5fa57b210adda03a53e4db840fc781228 /qt-ui
parent223d99f79f3b80bc45a6abc6d510f9250a181363 (diff)
downloadsubsurface-217c82f6c4207a5afe086d15edb29db59e523575.tar.gz
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/maintab.cpp15
1 files changed, 11 insertions, 4 deletions
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)