Changeset 82d37e74 in subsurface


Ignore:
Timestamp:
Apr 22, 2017, 1:49:07 PM (5 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
d82e200
Parents:
0bd02bf
git-author:
Dirk Hohndel <dirk@…> (04/22/17 13:49:03)
git-committer:
Dirk Hohndel <dirk@…> (04/22/17 13:49:07)
Message:

Download from divecomputer: don't show bogus progress text

On some divecomputers we download all the data from the device and
then parse the data afterwards just in memory (at which point the
progress bar has already run all the way to 100%). So don't try to
show the dive number and time in that case.

Fixes #335

Signed-off-by: Dirk Hohndel <dirk@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • desktop-widgets/downloadfromdivecomputer.cpp

    r0bd02bf r82d37e74  
    122122void DownloadFromDCWidget::updateProgressBar()
    123123{
    124         if (*progress_bar_text != '\0') {
     124        static char *last_text = NULL;
     125
     126        if (same_string(last_text, "")) {
     127                // if we get the first actual text after the download is finished
     128                // (which happens for example on the OSTC), then don't bother
     129                if (!same_string(progress_bar_text, "") && IS_FP_SAME(progress_bar_fraction, 1.0))
     130                        progress_bar_text = NULL;
     131        }
     132        if (!same_string(progress_bar_text , "")) {
    125133                ui.progressBar->setFormat(progress_bar_text);
    126134        } else {
     
    128136        }
    129137        ui.progressBar->setValue(lrint(progress_bar_fraction * 100));
     138        free(last_text);
     139        last_text = strdup(progress_bar_text);
    130140}
    131141
     
    140150                markChildrenAsEnabled();
    141151                timer->stop();
     152                progress_bar_text = "";
    142153        }
    143154
     
    161172                ui.progressBar->hide();
    162173                markChildrenAsEnabled();
     174                progress_bar_text = "";
    163175        }
    164176
     
    173185                        progress_bar_text = "";
    174186                } else {
     187                        progress_bar_text = "";
    175188                        ui.progressBar->setValue(100);
    176189                        markChildrenAsEnabled();
     
    192205                QMessageBox::critical(this, TITLE_OR_TEXT(tr("Error"), this->thread->error), QMessageBox::Ok);
    193206                markChildrenAsEnabled();
     207                progress_bar_text = "";
    194208                ui.progressBar->hide();
    195209        }
Note: See TracChangeset for help on using the changeset viewer.