diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2020-09-20 14:48:15 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2020-09-20 18:23:57 -0700 |
commit | f42dee8ac2e40e02ffd2b177f7d97e1b4ba8acea (patch) | |
tree | 70ac647cdd10f921562c674e1fc3e33398d2e21b | |
parent | 43390d4a9aa1a6c78e36ae2dd32e8421f9060c92 (diff) | |
download | subsurface-f42dee8ac2e40e02ffd2b177f7d97e1b4ba8acea.tar.gz |
selection: when changing current dive make sure it is selected
When an undo command selected invisible dives, a current dive outside
of the list of selected dives was chosen. This could have the very
unfortunate effect that the current dive was set, though not selected.
From an UI point of view this meant that the dive was displayed, but
edits would not be registered.
Change the setClosestCurrentDive function to select the current dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | ReleaseNotes/ReleaseNotes.txt | 2 | ||||
-rw-r--r-- | core/selection.cpp | 9 |
3 files changed, 10 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index e2dce6425..70f19c881 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -- update filter status when loading file [#2961] + --- * Always add new entries at the very top of this file above other existing entries and this note. diff --git a/ReleaseNotes/ReleaseNotes.txt b/ReleaseNotes/ReleaseNotes.txt index 7a888ee1c..5ea95ae60 100644 --- a/ReleaseNotes/ReleaseNotes.txt +++ b/ReleaseNotes/ReleaseNotes.txt @@ -10,6 +10,8 @@ New in _Subsurface_ 4.9.7 - profile: improve resolution in printing and export - core: fix renumbering of imported dives [#2731] - core: fix broken merging of dives with multiple cylinders +- core: make sure current dive is always selected [#2961] +- core: update filter status when loading dive list [#2961] - bluetooth/rfcomm: fix broken classic BT downloads on Linux and Windows; macOS is still broken - media: read timestamp from mvhd atom of QuickTime/MP4 style videos - planner: properly initialize salinity diff --git a/core/selection.cpp b/core/selection.cpp index d6267c78a..4912735b2 100644 --- a/core/selection.cpp +++ b/core/selection.cpp @@ -119,7 +119,10 @@ extern "C" void dump_selection(void) // or a newly selected dive. In both cases, try to select the // dive that is newer that is newer than the given date. // This mimics the old behavior when the current dive changed. -static void setClosestCurrentDive(timestamp_t when, const std::vector<dive *> &selection) +// If a current dive outside of the selection was set, add +// it to the list of selected dives, so that we never end up +// in a situation where we display a non-selected dive. +static void setClosestCurrentDive(timestamp_t when, const std::vector<dive *> &selection, QVector<dive *> &divesToSelect) { // Start from back until we get the first dive that is before // the supposed-to-be selected dive. (Note: this mimics the @@ -144,6 +147,8 @@ static void setClosestCurrentDive(timestamp_t when, const std::vector<dive *> &s // return null, but that just means unsetting the current dive (as no // dive is visible anyway). current_dive = find_next_visible_dive(when); + if (current_dive) + divesToSelect.push_back(current_dive); } // Reset the selection to the dives of the "selection" vector and send the appropriate signals. @@ -194,7 +199,7 @@ void setSelection(const std::vector<dive *> &selection, dive *currentDive) current_dive = currentDive; if (current_dive && !currentDive->selected) { // Current not visible -> find a different dive. - setClosestCurrentDive(currentDive->when, selection); + setClosestCurrentDive(currentDive->when, selection, divesToSelect); } // Send the new selection |