Showing the changes to interface/src/Application.cpp (1 of 5 files). Show all
Unified · Split
| @@ -11,6 +11,8 @@ · 10 unmodified lines | |||
| 11 | 11 | ||
| 12 | #include "Application.h" | 12 | #include "Application.h" |
| 13 | 13 | ||
| 14 | #include <thread> | ||
| 15 | |||
| 14 | #include <gl/Config.h> | 16 | #include <gl/Config.h> |
| 15 | #include <glm/glm.hpp> | 17 | #include <glm/glm.hpp> |
| 16 | #include <glm/gtx/component_wise.hpp> | 18 | #include <glm/gtx/component_wise.hpp> |
| @@ -1570,9 +1572,13 @@ void Application::aboutToQuit() { · 1553 unmodified lines | |||
| 1570 | 1572 | ||
| 1571 | getActiveDisplayPlugin()->deactivate(); | 1573 | getActiveDisplayPlugin()->deactivate(); |
| 1572 | 1574 | ||
| 1573 | // use the ClosureEventSender via an std::thread (to not use QThread while the application is going down) | 1575 | // use the ClosureEventSender via a QThread to send an event that says the user asked for the app to close |
| 1574 | // to send an event that says the user asked for the app to close | 1576 | auto closureEventSender = DependencyManager::get<ClosureEventSender>(); |
| 1575 | _userQuitThread = std::thread { &ClosureEventSender::sendQuitStart, DependencyManager::get<ClosureEventSender>() }; | 1577 | QThread* closureEventThread = new QThread(this); |
| 1578 | closureEventSender->moveToThread(closureEventThread); | ||
| 1579 | // sendQuitEventAsync will bail immediately if the UserActivityLogger is not enabled | ||
| 1580 | connect(closureEventThread, &QThread::started, closureEventSender.data(), &ClosureEventSender::sendQuitEventAsync); | ||
| 1581 | closureEventThread->start(); | ||
| 1576 | 1582 | ||
| 1577 | // Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown. | 1583 | // Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown. |
| 1578 | DependencyManager::get<OffscreenUi>()->hide("RunningScripts"); | 1584 | DependencyManager::get<OffscreenUi>()->hide("RunningScripts"); |
| @@ -1738,6 +1744,15 @@ Application::~Application() { · 159 unmodified lines | |||
| 1738 | 1744 | ||
| 1739 | _window->deleteLater(); | 1745 | _window->deleteLater(); |
| 1740 | 1746 | ||
| 1747 | // make sure that the quit event has finished sending before we take the application down | ||
| 1748 | auto closureEventSender = DependencyManager::get<ClosureEventSender>(); | ||
| 1749 | while (!closureEventSender->hasFinishedQuitEvent() && !closureEventSender->hasTimedOutQuitEvent()) { | ||
| 1750 | // yield so we're not spinning | ||
| 1751 | std::this_thread::yield(); | ||
| 1752 | } | ||
| 1753 | // quit the thread used by the closure event sender | ||
| 1754 | closureEventSender->thread()->quit(); | ||
| 1755 | |||
| 1741 | // Can't log to file passed this point, FileLogger about to be deleted | 1756 | // Can't log to file passed this point, FileLogger about to be deleted |
| 1742 | qInstallMessageHandler(LogHandler::verboseMessageHandler); | 1757 | qInstallMessageHandler(LogHandler::verboseMessageHandler); |
| 1743 | } | 1758 | } |