Ripper: Ensuring that GetProgress does never divide by zero
Also removed superfluous null check in RipCDDialog
This commit is contained in:
parent
f35e1b543d
commit
794c1b8c92
|
@ -213,10 +213,6 @@ void RipCDDialog::ClickedRipButton() {
|
||||||
|
|
||||||
// create and connect Ripper instance for this task
|
// create and connect Ripper instance for this task
|
||||||
Ripper* ripper = new Ripper(cdda_device_->song_count(), this);
|
Ripper* ripper = new Ripper(cdda_device_->song_count(), this);
|
||||||
if (!ripper) {
|
|
||||||
qLog(Error) << "Could not create Ripper instance";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(cancel_button_, SIGNAL(clicked()), ripper, SLOT(Cancel()));
|
connect(cancel_button_, SIGNAL(clicked()), ripper, SLOT(Cancel()));
|
||||||
|
|
||||||
|
|
|
@ -154,11 +154,14 @@ void Ripper::Rip() {
|
||||||
}
|
}
|
||||||
|
|
||||||
float Ripper::GetProgress() const {
|
float Ripper::GetProgress() const {
|
||||||
|
int added_tracks = AddedTracks();
|
||||||
|
if (added_tracks == 0) return 1.0f;
|
||||||
|
|
||||||
float progress = finished_success_ + finished_failed_;
|
float progress = finished_success_ + finished_failed_;
|
||||||
QList<float> current_job_progress_ = transcoder_->GetProgress().values();
|
QList<float> current_job_progress_ = transcoder_->GetProgress().values();
|
||||||
progress += std::accumulate(current_job_progress_.begin(),
|
progress += std::accumulate(current_job_progress_.begin(),
|
||||||
current_job_progress_.end(), 0.0f);
|
current_job_progress_.end(), 0.0f);
|
||||||
progress /= AddedTracks();
|
progress /= added_tracks;
|
||||||
|
|
||||||
qLog(Debug) << "Progress: " << progress;
|
qLog(Debug) << "Progress: " << progress;
|
||||||
return progress;
|
return progress;
|
||||||
|
|
Loading…
Reference in New Issue