Fix crash when no dives were selected for downloading

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Miika Turkia 2015-01-27 06:50:42 +02:00 committed by Dirk Hohndel
parent d5d42982b8
commit 6edc458e83

View file

@ -418,6 +418,8 @@ void DownloadFromDCWidget::on_cancel_clicked()
void DownloadFromDCWidget::on_ok_clicked() void DownloadFromDCWidget::on_ok_clicked()
{ {
struct dive *dive;
if (currentState != DONE) if (currentState != DONE)
return; return;
@ -433,16 +435,20 @@ void DownloadFromDCWidget::on_ok_clicked()
// remember the last downloaded dive (on most dive computers this will be the chronologically // remember the last downloaded dive (on most dive computers this will be the chronologically
// first new dive) and select it again after processing all the dives // first new dive) and select it again after processing all the dives
MainWindow::instance()->dive_list()->unselectDives(); MainWindow::instance()->dive_list()->unselectDives();
uniqId = get_dive(dive_table.nr - 1)->id;
process_dives(true, preferDownloaded()); dive = get_dive(dive_table.nr - 1);
// after process_dives does any merging or resorting needed, we need if (dive != NULL) {
// to recreate the model for the dive list so we can select the newest dive uniqId = get_dive(dive_table.nr - 1)->id;
MainWindow::instance()->recreateDiveList(); process_dives(true, preferDownloaded());
idx = get_idx_by_uniq_id(uniqId); // after process_dives does any merging or resorting needed, we need
// this shouldn't be necessary - but there are reports that somehow existing dives stay selected // to recreate the model for the dive list so we can select the newest dive
// (but not visible as selected) MainWindow::instance()->recreateDiveList();
MainWindow::instance()->dive_list()->unselectDives(); idx = get_idx_by_uniq_id(uniqId);
MainWindow::instance()->dive_list()->selectDive(idx, true); // this shouldn't be necessary - but there are reports that somehow existing dives stay selected
// (but not visible as selected)
MainWindow::instance()->dive_list()->unselectDives();
MainWindow::instance()->dive_list()->selectDive(idx, true);
}
if (ostcFirmwareCheck && currentState == DONE) if (ostcFirmwareCheck && currentState == DONE)
ostcFirmwareCheck->checkLatest(this, &data); ostcFirmwareCheck->checkLatest(this, &data);