summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-08-01 10:47:09 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-11 16:22:27 -0700
commit0d98da52610161ecbafd50afacbff20996756264 (patch)
tree686947161c92eb96329512af1dcc4d4a18af4fef /core
parent96d87273995a6af35d90efb1190ff653e4c03d02 (diff)
downloadsubsurface-0d98da52610161ecbafd50afacbff20996756264.tar.gz
Dive list: remember selected dives
Don't delesect dives, when unregistering them from the backend. If a previously selected dive is added, select it in the dive-list. For this purpose introduce a SELECTED_ROLE to query the DiveTripModel for selected dives. Unfortunately, when adding multiple selected dives, current_dive_changed is called for each of them, making this very slow. This will have to be fixed in subsequent commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/divelist.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/core/divelist.c b/core/divelist.c
index 902bbb5ac..1c6ad9fc0 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -1065,9 +1065,9 @@ struct dive *unregister_dive(int idx)
if (!dive)
return NULL; /* this should never happen */
remove_dive_from_trip(dive, false);
- if (dive->selected)
- deselect_dive(idx);
unregister_dive_from_table(&dive_table, idx);
+ if (dive->selected)
+ amount_selected--;
return dive;
}
@@ -1075,7 +1075,12 @@ struct dive *unregister_dive(int idx)
* but doesn't deal with updating dive trips, etc */
void delete_single_dive(int idx)
{
- struct dive *dive = unregister_dive(idx);
+ struct dive *dive = get_dive(idx);
+ if (!dive)
+ return; /* this should never happen */
+ if (dive->selected)
+ deselect_dive(idx);
+ dive = unregister_dive(idx);
free_dive(dive);
}