From 01d7e68dbb8d7689c0d31e76e9ea57d0604f7fdc Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 9 Sep 2015 11:29:57 -0700 Subject: [PATCH 1/2] Terminate DDE earlier during shut-down and always at start-up --- interface/src/Application.cpp | 15 ++++++++------- interface/src/devices/DdeFaceTracker.cpp | 5 ++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 08a8af89f0..167d760cf5 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -786,6 +786,14 @@ void Application::aboutToQuit() { } void Application::cleanupBeforeQuit() { + // Terminate third party processes so that they're not left running in the event of a subsequent shutdown crash +#ifdef HAVE_DDE + DependencyManager::destroy(); +#endif +#ifdef HAVE_IVIEWHMD + DependencyManager::destroy(); +#endif + if (_keyboardFocusHighlightID > 0) { getOverlays().deleteOverlay(_keyboardFocusHighlightID); _keyboardFocusHighlightID = -1; @@ -833,13 +841,6 @@ void Application::cleanupBeforeQuit() { // destroy the AudioClient so it and its thread have a chance to go down safely DependencyManager::destroy(); - -#ifdef HAVE_DDE - DependencyManager::destroy(); -#endif -#ifdef HAVE_IVIEWHMD - DependencyManager::destroy(); -#endif } void Application::emptyLocalCache() { diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index 396539c3cf..02cdb4bad8 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -254,9 +254,8 @@ void DdeFaceTracker::setEnabled(bool enabled) { _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); - } - - if (!enabled && _ddeProcess) { + } else { + // Send a command to stop face tracker evening if no _ddeProcess in case DDE has been left running after a crash _ddeStopping = true; _udpSocket.writeDatagram(DDE_EXIT_COMMAND, DDE_SERVER_ADDR, _controlPort); qCDebug(interfaceapp) << "DDE Face Tracker: Stopping"; From fdcfa9657c2523333d63264c18b072a79ca8a52a Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 9 Sep 2015 21:06:50 -0700 Subject: [PATCH 2/2] Rework and clarify stopping an existing DDE process --- interface/src/devices/DdeFaceTracker.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/interface/src/devices/DdeFaceTracker.cpp b/interface/src/devices/DdeFaceTracker.cpp index 02cdb4bad8..2ddd8d9d04 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -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