diff options
-rw-r--r-- | subsurface-core/divelist.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/subsurface-core/divelist.c b/subsurface-core/divelist.c index a14fabf88..a2e94c067 100644 --- a/subsurface-core/divelist.c +++ b/subsurface-core/divelist.c @@ -790,6 +790,9 @@ void add_single_dive(int idx, struct dive *dive) dive_table.nr++; if (dive->selected) amount_selected++; + if (idx < 0) + // convert an idx of -1 so we do insert-at-end: + idx = dive_table.nr - 1; for (i = idx; i < dive_table.nr; i++) { struct dive *tmp = dive_table.dives[i]; dive_table.dives[i] = dive; |