forked from Silverfish/proton-bridge
GODT-1671: Implement Quit & Restart mechanism
This commit is contained in:
@ -34,7 +34,7 @@ QString const exeSuffix = ".exe";
|
||||
QString const exeSuffix;
|
||||
#endif
|
||||
|
||||
QString const exeName = "bridge" + exeSuffix; ///< The bridge executable file name.
|
||||
QString const exeName = "proton-bridge" + exeSuffix; ///< The bridge executable file name.*
|
||||
|
||||
|
||||
}
|
||||
@ -55,9 +55,10 @@ QString BridgeMonitor::locateBridgeExe()
|
||||
/// \param[in] exePath The path of the Bridge executable.
|
||||
/// \param[in] parent The parent object of the worker.
|
||||
//****************************************************************************************************************************************************
|
||||
BridgeMonitor::BridgeMonitor(QString const &exePath, QObject *parent)
|
||||
BridgeMonitor::BridgeMonitor(QString const &exePath, QStringList const &args, QObject *parent)
|
||||
: Worker(parent)
|
||||
, exePath_(exePath)
|
||||
, args_(args)
|
||||
{
|
||||
QFileInfo fileInfo(exePath);
|
||||
if (!fileInfo.exists())
|
||||
@ -77,16 +78,23 @@ void BridgeMonitor::run()
|
||||
emit started();
|
||||
|
||||
QProcess p;
|
||||
p.start(exePath_, QStringList());
|
||||
p.start(exePath_, args_);
|
||||
p.waitForStarted();
|
||||
|
||||
status_.running = true;
|
||||
status_.pid = p.processId();
|
||||
|
||||
while (!p.waitForFinished(100))
|
||||
{
|
||||
// we discard output from bridge, it's logged to file on bridge side.
|
||||
p.readAllStandardError();
|
||||
p.readAllStandardOutput();
|
||||
}
|
||||
emit processExited(p.exitCode());
|
||||
|
||||
status_.running = false;
|
||||
status_.returnCode = p.exitCode();
|
||||
|
||||
emit processExited(status_.returnCode );
|
||||
emit finished();
|
||||
}
|
||||
catch (Exception const &e)
|
||||
@ -94,3 +102,11 @@ void BridgeMonitor::run()
|
||||
emit error(e.qwhat());
|
||||
}
|
||||
}
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return status of the monitored process
|
||||
//****************************************************************************************************************************************************
|
||||
const BridgeMonitor::MonitorStatus& BridgeMonitor::getStatus()
|
||||
{
|
||||
return status_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user