aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-03-31 13:54:23 +0200
committerGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2021-03-31 13:54:23 +0200
commita988e3c135f8ad356b91edaede706770f5a3ab74 (patch)
tree577a4318b46f9e93805283126da3d73454aebd3b /core
parentf299fa37f992be20f01c130bb407b321e0c69d63 (diff)
downloadsubsurface-a988e3c135f8ad356b91edaede706770f5a3ab74.tar.gz
core: initialize dive selection after resetting the data
The dive selection was initialized during data-reset. However, this emitted a signal before all data-reset routines were run. Ultimately, this led to access-after-free in the statistics code. Instead, move the select_newest_visible_dive() signal from the divelist-model to the process_loaded_dives() function. There is no point in initializing the selection if the dive data is cleared after all. This change broke closing of the log, because the UI-selection was not reset. Therefore, when clearing the data, clear the selection before proceeding with clearing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core')
-rw-r--r--core/divelist.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/divelist.c b/core/divelist.c
index 379e33eea..a1420e407 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -824,6 +824,9 @@ void process_loaded_dives()
/* Inform frontend of reset data. This should reset all the models. */
emit_reset_signal();
+
+ /* Now that everything is settled, select the newest dive. */
+ select_newest_visible_dive();
}
/*
@@ -1373,7 +1376,7 @@ int get_dive_id_closest_to(timestamp_t when)
void clear_dive_file_data()
{
fulltext_unregister_all();
- clear_selection();
+ select_single_dive(NULL); // This is propagate up to the UI and clears all the information.
while (dive_table.nr)
delete_single_dive(0);