summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-12 15:30:11 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-10-13 11:32:27 -0700
commit5f11c94f02eca651e07f5a0c2cc4e55dcbf2df0b (patch)
tree59c0d4ad90adc5f4bc4df1796f4ba744f1afef8e
parent4fb2f89bb5df643672fe95b382d92a18e0894c19 (diff)
downloadsubsurface-5f11c94f02eca651e07f5a0c2cc4e55dcbf2df0b.tar.gz
Mobile: improve helper function to track selected dives
While on mobile there should always be only one selected dive, it's very cheap to make sure that amount_selected is tracked correctly. The incrementing of amount_selected is done in case an invalid id is passed in. Suggested-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--mobile-widgets/qmlmanager.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 08ce7fca7..aab3f1d08 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -1378,10 +1378,17 @@ bool QMLManager::undoDelete(int id)
void QMLManager::selectDive(int id)
{
int i;
+ extern int amount_selected;
struct dive *dive = NULL;
- for_each_dive (i, dive)
+ amount_selected = 0;
+ for_each_dive (i, dive) {
dive->selected = (dive->id == id);
+ if (dive->selected)
+ amount_selected++;
+ }
+ if (amount_selected == 0)
+ qWarning("QManager::selectDive() called with unknown id");
}
void QMLManager::deleteDive(int id)