From: Kern Sibbald Date: Sat, 25 Dec 2010 12:56:58 +0000 (+0100) Subject: Ensure that Job duration is not negative X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=cdac3873cfc0500ffc962d34ec8ec988807f3fa3;p=bacula%2Fbacula Ensure that Job duration is not negative --- diff --git a/bacula/src/qt-console/job/job.cpp b/bacula/src/qt-console/job/job.cpp index 20514cec5b..c9db572e62 100644 --- a/bacula/src/qt-console/job/job.cpp +++ b/bacula/src/qt-console/job/job.cpp @@ -223,7 +223,7 @@ void Job::populateForm() "WHERE JobId=" + m_jobId; QStringList results; if (m_console->sql_cmd(query, results)) { - QString resultline; + QString resultline, duration; QStringList fieldlist; foreach (resultline, results) { // should have only one result @@ -240,14 +240,23 @@ void Job::populateForm() label_SchedTime->setText(fld.next()); label_StartTime->setText(fld.next()); label_EndTime->setText(fld.next()); - label_Duration->setText(fld.next()); + duration = fld.next(); + /* + * Note: if we have a negative duration, it is because the EndTime + * is zero (i.e. the Job is still running). We should use + * duration = StartTime - current_time + */ + if (duration.left(1) == "-") { + duration = "0.0"; + } + label_Duration->setText(duration); label_JobBytes->setText(convertBytesSI(fld.next().toULongLong())); label_JobFiles->setText(fld.next()); err = fld.next(); label_JobErrors->setText(err); - stat=fld.next(); + stat = fld.next(); if (stat == "T" && err.toInt() > 0) { stat = "W"; }