#1710 #1665 Wait for octave process to finish when executing through command file interface

This commit is contained in:
Bjørnar Grip Fjær 2017-07-31 11:10:22 +02:00
parent 94703d72c2
commit 48401d5a85
3 changed files with 26 additions and 0 deletions

View File

@ -217,6 +217,8 @@ RiaApplication::RiaApplication(int& argc, char** argv)
m_runningRegressionTests = false;
m_runningWorkerProcess = false;
m_mainPlotWindow = NULL;
m_recentFileActionProvider = std::unique_ptr<RiuRecentFileActionProvider>(new RiuRecentFileActionProvider);
@ -1943,6 +1945,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu
if (exitStatus == QProcess::CrashExit)
{
// MFLog::error("Simulation execution crashed or was aborted.");
m_runningWorkerProcess = false;
return;
}
@ -1954,6 +1957,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu
if (exitCode != 0)
{
// MFLog::error(QString("Simulation execution failed (exit code %1).").arg(exitCode));
m_runningWorkerProcess = false;
return;
}
@ -1966,6 +1970,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu
{
// Disable concept of current case
m_socketServer->setCurrentCaseId(-1);
m_runningWorkerProcess = false;
}
}
@ -1990,6 +1995,7 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar
m_socketServer->setCurrentCaseId(-1);
}
m_runningWorkerProcess = true;
m_workerProcess = new caf::UiProcess(this);
QProcessEnvironment penv = QProcessEnvironment::systemEnvironment();
@ -2026,6 +2032,7 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar
{
m_workerProcess->close();
m_workerProcess = NULL;
m_runningWorkerProcess = false;
RiuMainWindow::instance()->processMonitor()->stopMonitorWorkProcess();
@ -2145,9 +2152,21 @@ void RiaApplication::terminateProcess()
m_workerProcess->close();
}
m_runningWorkerProcess = false;
m_workerProcess = NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaApplication::waitForProcess() const
{
while (m_runningWorkerProcess)
{
Sleep(100);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -165,6 +165,7 @@ public:
bool launchProcess(const QString& program, const QStringList& arguments);
bool launchProcessForMultipleCases(const QString& program, const QStringList& arguments, const std::vector<int>& caseIds);
void terminateProcess();
void waitForProcess() const;
RiaPreferences* preferences();
void applyPreferences();
@ -267,6 +268,8 @@ private:
QString m_helpText;
bool m_runningRegressionTests;
bool m_runningWorkerProcess;
RiuMainPlotWindow* m_mainPlotWindow;
std::unique_ptr<RiuRecentFileActionProvider> m_recentFileActionProvider;

View File

@ -60,4 +60,8 @@ void RicfRunOctaveScript::execute()
{
RiaLogging::error(QString("runOctaveScript: Could not execute script %1").arg(m_path()));
}
else
{
RiaApplication::instance()->waitForProcess();
}
}