diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index e8f29619fa..793a1034f4 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; @@ -834,13 +842,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..2ddd8d9d04 100644 --- a/interface/src/devices/DdeFaceTracker.cpp +++ b/interface/src/devices/DdeFaceTracker.cpp @@ -236,29 +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); } - + if (!enabled && _ddeProcess) { _ddeStopping = true; - _udpSocket.writeDatagram(DDE_EXIT_COMMAND, DDE_SERVER_ADDR, _controlPort); qCDebug(interfaceapp) << "DDE Face Tracker: Stopping"; } #endif