diff --git a/GUI/Model/Job/JobItem.cpp b/GUI/Model/Job/JobItem.cpp index 7d7f32d30f82856becddbd2ddff6be8a932502f1..6452a8d47f82adafd1d318c5f2f6005de99c0e7d 100644 --- a/GUI/Model/Job/JobItem.cpp +++ b/GUI/Model/Job/JobItem.cpp @@ -358,6 +358,7 @@ void JobItem::onFinishedWork() if (isFailed(worker()->workerStatus())) batchInfo()->setComments(worker()->workerFailureMessage()); else { + batchInfo()->setComments(""); ASSERT(worker()->workerResult()); simulatedDataItem()->setDatafield(*worker()->workerResult()); updateFileName(); diff --git a/GUI/View/Job/JobMessagesDisplay.cpp b/GUI/View/Job/JobMessagesDisplay.cpp index 35db511925c102a87f9421eaccb134c1f818d129..602b5e610a910ce635fa5ad951923e83fdfa3bf7 100644 --- a/GUI/View/Job/JobMessagesDisplay.cpp +++ b/GUI/View/Job/JobMessagesDisplay.cpp @@ -50,11 +50,13 @@ void JobMessagesDisplay::setJobItem(JobItem* jobItem) m_comments_editor->clear(); return; } - const bool ok = isFailed(m_job_item->batchInfo()->status()); - m_comments_editor->setTextColor(ok ? Qt::black : Qt::red); + onJobStatusChanged(m_job_item->batchInfo()->status()); + onJobCommentsChanged(m_job_item->batchInfo()->comments()); connect(m_job_item, &QObject::destroyed, this, &JobMessagesDisplay::onJobDestroyed, Qt::UniqueConnection); + connect(m_job_item->batchInfo(), &BatchInfo::jobStatusChanged, this, + &JobMessagesDisplay::onJobStatusChanged, Qt::UniqueConnection); connect(m_job_item->batchInfo(), &BatchInfo::jobCommentsChanged, this, &JobMessagesDisplay::onJobCommentsChanged, Qt::UniqueConnection); } @@ -64,18 +66,25 @@ void JobMessagesDisplay::onCommentsEdited() if (!m_job_item) return; - m_job_item->batchInfo()->blockSignals(true); + QSignalBlocker b(m_job_item->batchInfo()); m_job_item->batchInfo()->setComments(m_comments_editor->toPlainText()); - m_job_item->batchInfo()->blockSignals(false); } void JobMessagesDisplay::onJobCommentsChanged(const QString& comments) { - ASSERT(m_job_item) - - m_comments_editor->blockSignals(true); + QSignalBlocker b(m_comments_editor); m_comments_editor->setPlainText(comments); - m_comments_editor->blockSignals(false); +} + +void JobMessagesDisplay::onJobStatusChanged(JobStatus status) +{ + if (isRunning(status)) + return; + + QSignalBlocker b(m_comments_editor); + + m_comments_editor->setTextColor(isFailed(status) ? Qt::red : Qt::black); + m_comments_editor->setPlainText(m_comments_editor->toPlainText()); } void JobMessagesDisplay::onJobDestroyed() diff --git a/GUI/View/Job/JobMessagesDisplay.h b/GUI/View/Job/JobMessagesDisplay.h index da58d10e40d04a671b4a8f8ce14c0316c85e5863..3634a4290d2a051f01dce347d10d8998612081dc 100644 --- a/GUI/View/Job/JobMessagesDisplay.h +++ b/GUI/View/Job/JobMessagesDisplay.h @@ -19,6 +19,8 @@ class JobItem; +enum class JobStatus; + //! Holds tabs for properties view and comments editor. class JobMessagesDisplay : public QWidget { @@ -30,6 +32,7 @@ public: private slots: void onCommentsEdited(); void onJobCommentsChanged(const QString& comments); + void onJobStatusChanged(JobStatus status); void onJobDestroyed(); private: