mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 05:33:23 +00:00
Fix selection tracking bug
When trying to remember a newly manually created dive across the sort_table() call I abused the dive->selected flag and didn't clear it out afterwards (most likely thinking "hey, I'm calling selectDive() on this anyway"). This caused the UI code to correctly mark the dive as selected, but when it called down to the C code to keep the internal data structures in sync, that code didn't update amount_selected as it thought this dive had already been selected. And that caused other parts of the code to get confused, which manifested for example in the failed upload to divelogs.de. So this clears out the flag after abusing it to remember a dive. Maybe we should add a 'remembered' flag instead, but for now this fixes the issue. Fixes #351 Initial-fix-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
eaa3160082
commit
e5561d7668
1 changed files with 7 additions and 4 deletions
|
@ -638,18 +638,21 @@ void MainTab::acceptChanges()
|
|||
if(editMode == ADD || editMode == MANUALLY_ADDED_DIVE){
|
||||
mainWindow()->dive_list()->unselectDives();
|
||||
struct dive *d = get_dive(dive_table.nr -1 );
|
||||
// HACK. this shouldn't be here. but apparently it's
|
||||
// how we can know what was the newly added dive.
|
||||
// mark the dive as remembered (abusing the selected flag)
|
||||
// and then clear that flag out on the other side of the sort_table()
|
||||
d->selected = true;
|
||||
sort_table(&dive_table);
|
||||
int i = 0;
|
||||
for_each_dive(i,d){
|
||||
if (d->selected) break;
|
||||
if (d->selected) {
|
||||
d->selected = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
editMode = NONE;
|
||||
mainWindow()->refreshDisplay();
|
||||
mainWindow()->dive_list()->selectDive( i, true );
|
||||
}else{
|
||||
} else {
|
||||
editMode = NONE;
|
||||
mainWindow()->dive_list()->rememberSelection();
|
||||
sort_table(&dive_table);
|
||||
|
|
Loading…
Add table
Reference in a new issue