Rework and clarify stopping an existing DDE process

This commit is contained in:
David Rowe 2015-09-09 21:06:50 -07:00
parent 01d7e68dbb
commit fdcfa9657c

View file

@ -236,28 +236,25 @@ void DdeFaceTracker::setEnabled(bool enabled) {
cancelCalibration();
}
// isOpen() does not work as one might expect on QUdpSocket; don't test isOpen() before closing socket.
_udpSocket.close();
if (enabled) {
_udpSocket.bind(_host, _serverPort);
}
// Terminate any existing DDE process, perhaps left running after an Interface crash.
// Do this even if !enabled in case user reset their settings after crash.
const char* DDE_EXIT_COMMAND = "exit";
_udpSocket.bind(_host, _serverPort);
_udpSocket.writeDatagram(DDE_EXIT_COMMAND, DDE_SERVER_ADDR, _controlPort);
if (enabled && !_ddeProcess) {
// Terminate any existing DDE process, perhaps left running after an Interface crash
_udpSocket.writeDatagram(DDE_EXIT_COMMAND, DDE_SERVER_ADDR, _controlPort);
_ddeStopping = false;
qCDebug(interfaceapp) << "DDE Face Tracker: Starting";
_ddeProcess = new QProcess(qApp);
connect(_ddeProcess, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(processFinished(int, QProcess::ExitStatus)));
_ddeProcess->start(QCoreApplication::applicationDirPath() + DDE_PROGRAM_PATH, DDE_ARGUMENTS);
} else {
// Send a command to stop face tracker evening if no _ddeProcess in case DDE has been left running after a crash
}
if (!enabled && _ddeProcess) {
_ddeStopping = true;
_udpSocket.writeDatagram(DDE_EXIT_COMMAND, DDE_SERVER_ADDR, _controlPort);
qCDebug(interfaceapp) << "DDE Face Tracker: Stopping";
}
#endif