diff --git a/copasi/UI/CProgressBar.cpp b/copasi/UI/CProgressBar.cpp index 43d34286c3..3cbb0bfcac 100644 --- a/copasi/UI/CProgressBar.cpp +++ b/copasi/UI/CProgressBar.cpp @@ -176,34 +176,6 @@ bool CProgressBar::progressItem(const size_t & handle) if (!isValidHandle(handle) || mProgressItemList[handle] == NULL) return false; - QDateTime currDateTime = QDateTime::currentDateTime(); - - if (mNextEventProcessing >= currDateTime) - return proceed(); - - mNextEventProcessing = currDateTime.addSecs(1); - - if (mProccessingInstruction == ProccessingInstruction::Pause) - { - QMutexLocker Locker(&mMutex); - mWaitPause.wait(&mMutex); - } - - if (!CopasiUI3Window::isMainThread()) - { - if (mSlotFinished) - { - mSlotFinished = false; - - emit signalProgressAll(); - } - } - else - { - slotProgressAll(); - QCoreApplication::processEvents(); - } - return proceed(); } @@ -222,6 +194,7 @@ void CProgressBar::slotProgressAll() mSlotFinished = true; } +// virtual bool CProgressBar::finish() { // Assure that all signals have been properly handled before we delete @@ -250,11 +223,9 @@ bool CProgressBar::finish() } CopasiUI3Window::getMainWindow()->disableSliders(false); - - CProcessReport::finish(); done(1); - return proceed(); + return CProcessReport::finish(); } bool CProgressBar::finishItem(const size_t & handle) @@ -305,6 +276,40 @@ void CProgressBar::slotFinishItem(const int handle) mWaitSlot.wakeAll(); } +// virtual +bool CProgressBar::proceed() +{ + if (mProccessingInstruction == ProccessingInstruction::Pause) + { + QMutexLocker Locker(&mMutex); + mWaitPause.wait(&mMutex); + } + + QDateTime currDateTime = QDateTime::currentDateTime(); + + if (mNextEventProcessing < currDateTime) + { + mNextEventProcessing = currDateTime.addSecs(1); + + if (!CopasiUI3Window::isMainThread()) + { + if (mSlotFinished) + { + mSlotFinished = false; + + emit signalProgressAll(); + } + } + else + { + slotProgressAll(); + QCoreApplication::processEvents(); + } + } + + return CProcessReport::proceed(); +} + // virtual bool CProgressBar::setName(const std::string & name) { diff --git a/copasi/UI/CProgressBar.h b/copasi/UI/CProgressBar.h index 99200a26ad..0ace431e8d 100644 --- a/copasi/UI/CProgressBar.h +++ b/copasi/UI/CProgressBar.h @@ -90,6 +90,15 @@ class CProgressBar : public CQProgressDialog, public CProcessReport */ virtual bool finishItem(const size_t & handle) override; + /** + * Check whether processing shall proceed. If the return value is false + * the calling process must halt execution and return. This method is + * provided so that lengthy processing without advances in any of the + * reporting items can check whether continuation is requested. + * @param bool continue + */ + virtual bool proceed() override; + /** * Set the name of the process. * @param const std::string & name diff --git a/copasi/utilities/CProcessReport.cpp b/copasi/utilities/CProcessReport.cpp index 9694772b43..e1e5a689aa 100644 --- a/copasi/utilities/CProcessReport.cpp +++ b/copasi/utilities/CProcessReport.cpp @@ -177,7 +177,6 @@ bool CProcessReport::proceed() return false; return mProccessingInstruction == ProccessingInstruction::Continue - || mProccessingInstruction == ProccessingInstruction::Pause || (mIgnoreStop && mProccessingInstruction == ProccessingInstruction::Stop); } diff --git a/copasi/utilities/CProcessReport.h b/copasi/utilities/CProcessReport.h index 0e865c4a31..93bfc1187f 100644 --- a/copasi/utilities/CProcessReport.h +++ b/copasi/utilities/CProcessReport.h @@ -148,7 +148,7 @@ class CProcessReport * reporting items can check whether continuation is requested. * @param bool continue */ - bool proceed(); + virtual bool proceed(); /** * Reset all item handle. This means that the values of the items have changed