start musrview as detached process: simplifies things.
This commit is contained in:
@ -2555,9 +2555,7 @@ void PTextEdit::musrView()
|
|||||||
if (fAdmin->getMusrviewShowOneToOneFlag())
|
if (fAdmin->getMusrviewShowOneToOneFlag())
|
||||||
arg << "-1";
|
arg << "-1";
|
||||||
|
|
||||||
QProcess *proc = new QProcess(this);
|
QProcess proc;
|
||||||
connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(musrViewFinished(int, QProcess::ExitStatus)));
|
|
||||||
|
|
||||||
// make sure that the system environment variables are properly set
|
// make sure that the system environment variables are properly set
|
||||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||||
#if defined(Q_OS_DARWIN)
|
#if defined(Q_OS_DARWIN)
|
||||||
@ -2565,34 +2563,15 @@ void PTextEdit::musrView()
|
|||||||
#else
|
#else
|
||||||
env.insert("LD_LIBRARY_PATH", env.value("ROOTSYS") + "/lib:" + env.value("LD_LIBRARY_PATH"));
|
env.insert("LD_LIBRARY_PATH", env.value("ROOTSYS") + "/lib:" + env.value("LD_LIBRARY_PATH"));
|
||||||
#endif
|
#endif
|
||||||
proc->setProcessEnvironment(env);
|
proc.setProgram(cmd);
|
||||||
proc->setWorkingDirectory(workDir);
|
proc.setProcessEnvironment(env);
|
||||||
proc->start(cmd, arg);
|
if (!proc.startDetached(cmd, arg, workDir)) {
|
||||||
if (!proc->waitForStarted()) {
|
|
||||||
// error handling
|
|
||||||
QString msg(tr("Could not execute the output command: ")+cmd[0]);
|
|
||||||
QMessageBox::critical( nullptr,
|
|
||||||
tr("Fatal error"),
|
|
||||||
msg,
|
|
||||||
tr("Quit") );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>Checks if musrview terminated with error, and if yes pop up a message box.
|
|
||||||
* @param exitCode
|
|
||||||
*/
|
|
||||||
void PTextEdit::musrViewFinished(int exitCode, QProcess::ExitStatus)
|
|
||||||
{
|
|
||||||
if (exitCode != 0) {
|
|
||||||
QString msg = QString("musrview failed. Possible reasons:\n");
|
QString msg = QString("musrview failed. Possible reasons:\n");
|
||||||
msg += QString("* corrupted msr-file.\n");
|
msg += QString("* corrupted msr-file.\n");
|
||||||
msg += QString("* cannot read data-file.\n");
|
msg += QString("* cannot read data-file.\n");
|
||||||
msg += QString("* many more things can go wrong.\n");
|
msg += QString("* many more things can go wrong.\n");
|
||||||
msg += QString("Please check!");
|
msg += QString("Please check!");
|
||||||
QMessageBox::critical(nullptr, tr("Fatal Error"), msg, tr("Quit"));
|
QMessageBox::critical(nullptr, tr("FATAL ERROR"), msg, QMessageBox::Close);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,6 @@ private slots:
|
|||||||
void musrFit();
|
void musrFit();
|
||||||
void musrMsr2Data();
|
void musrMsr2Data();
|
||||||
void musrView();
|
void musrView();
|
||||||
void musrViewFinished(int, QProcess::ExitStatus);
|
|
||||||
void musrT0();
|
void musrT0();
|
||||||
void musrFT();
|
void musrFT();
|
||||||
void musrPrefs();
|
void musrPrefs();
|
||||||
|
@ -2555,9 +2555,7 @@ void PTextEdit::musrView()
|
|||||||
if (fAdmin->getMusrviewShowOneToOneFlag())
|
if (fAdmin->getMusrviewShowOneToOneFlag())
|
||||||
arg << "-1";
|
arg << "-1";
|
||||||
|
|
||||||
QProcess *proc = new QProcess(this);
|
QProcess proc;
|
||||||
connect(proc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(musrViewFinished(int, QProcess::ExitStatus)));
|
|
||||||
|
|
||||||
// make sure that the system environment variables are properly set
|
// make sure that the system environment variables are properly set
|
||||||
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||||
#if defined(Q_OS_DARWIN)
|
#if defined(Q_OS_DARWIN)
|
||||||
@ -2565,31 +2563,15 @@ void PTextEdit::musrView()
|
|||||||
#else
|
#else
|
||||||
env.insert("LD_LIBRARY_PATH", env.value("ROOTSYS") + "/lib:" + env.value("LD_LIBRARY_PATH"));
|
env.insert("LD_LIBRARY_PATH", env.value("ROOTSYS") + "/lib:" + env.value("LD_LIBRARY_PATH"));
|
||||||
#endif
|
#endif
|
||||||
proc->setProcessEnvironment(env);
|
proc.setProgram(cmd);
|
||||||
proc->setWorkingDirectory(workDir);
|
proc.setProcessEnvironment(env);
|
||||||
proc->start(cmd, arg);
|
if (!proc.startDetached(cmd, arg, workDir)) {
|
||||||
if (!proc->waitForStarted()) {
|
QString msg = QString("musrview failed. Possible reasons:\n");
|
||||||
// error handling
|
msg += QString("* corrupted msr-file.\n");
|
||||||
QString msg(tr("Could not execute the output command: ")+cmd[0]);
|
msg += QString("* cannot read data-file.\n");
|
||||||
QMessageBox::critical( nullptr, tr("FATAL ERROR"), msg, QMessageBox::Close );
|
msg += QString("* many more things can go wrong.\n");
|
||||||
return;
|
msg += QString("Please check!");
|
||||||
}
|
QMessageBox::critical(nullptr, tr("FATAL ERROR"), msg, QMessageBox::Close);
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
|
||||||
/**
|
|
||||||
* <p>Checks if musrview terminated with error, and if yes pop up a message box.
|
|
||||||
* @param exitCode
|
|
||||||
*/
|
|
||||||
void PTextEdit::musrViewFinished(int exitCode, QProcess::ExitStatus)
|
|
||||||
{
|
|
||||||
if (exitCode != 0) {
|
|
||||||
QString msg = QString("musrview failed. Possible reasons:\n");
|
|
||||||
msg += QString("* corrupted msr-file.\n");
|
|
||||||
msg += QString("* cannot read data-file.\n");
|
|
||||||
msg += QString("* many more things can go wrong.\n");
|
|
||||||
msg += QString("Please check!");
|
|
||||||
QMessageBox::critical(nullptr, tr("FATAL ERROR"), msg, QMessageBox::Close);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,7 +140,6 @@ private slots:
|
|||||||
void musrFit();
|
void musrFit();
|
||||||
void musrMsr2Data();
|
void musrMsr2Data();
|
||||||
void musrView();
|
void musrView();
|
||||||
void musrViewFinished(int, QProcess::ExitStatus);
|
|
||||||
void musrT0();
|
void musrT0();
|
||||||
void musrFT();
|
void musrFT();
|
||||||
void musrPrefs();
|
void musrPrefs();
|
||||||
|
Reference in New Issue
Block a user