Showing the changes to interface/src/Application.cpp (1 of 52 files). Show all
Unified · Split
| @@ -653,6 +653,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 652 unmodified lines | ||
| 653 | 653 | Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us |
| 654 | 654 | |
| 655 | 655 | auto nodeList = DependencyManager::get<NodeList>(); |
| 656 | + nodeList->startThread(); | |
| 656 | 657 | |
| 657 | 658 | // Set up a watchdog thread to intentionally crash the application on deadlocks |
| 658 | 659 | _deadlockWatchdogThread = new DeadlockWatchdogThread(); |
| @@ -678,25 +679,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 19 unmodified lines | ||
| 678 | 679 | |
| 679 | 680 | updateHeartbeat(); |
| 680 | 681 | |
| 681 | − // start the nodeThread so its event loop is running | |
| 682 | − QThread* nodeThread = new QThread(this); | |
| 683 | − nodeThread->setObjectName("NodeList Thread"); | |
| 684 | − nodeThread->start(); | |
| 685 | − | |
| 686 | − // make sure the node thread is given highest priority | |
| 687 | − nodeThread->setPriority(QThread::TimeCriticalPriority); | |
| 688 | − | |
| 689 | 682 | // setup a timer for domain-server check ins |
| 690 | 683 | QTimer* domainCheckInTimer = new QTimer(nodeList.data()); |
| 691 | 684 | connect(domainCheckInTimer, &QTimer::timeout, nodeList.data(), &NodeList::sendDomainServerCheckIn); |
| 692 | 685 | domainCheckInTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS); |
| 693 | 686 | |
| 694 | − // put the NodeList and datagram processing on the node thread | |
| 695 | − nodeList->moveToThread(nodeThread); | |
| 696 | − | |
| 697 | − // put the audio processing on a separate thread | |
| 698 | − QThread* audioThread = new QThread(); | |
| 699 | − audioThread->setObjectName("Audio Thread"); | |
| 700 | 687 | |
| 701 | 688 | auto audioIO = DependencyManager::get<AudioClient>(); |
| 702 | 689 | audioIO->setPositionGetter([]{ |
| @@ -712,7 +699,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 9 unmodified lines | ||
| 712 | 699 | return myAvatar ? myAvatar->getOrientationForAudio() : Quaternions::IDENTITY; |
| 713 | 700 | }); |
| 714 | 701 | |
| 715 | − audioIO->moveToThread(audioThread); | |
| 716 | 702 | recording::Frame::registerFrameHandler(AudioConstants::getAudioFrameName(), [=](recording::Frame::ConstPointer frame) { |
| 717 | 703 | audioIO->handleRecordedAudioInput(frame->data); |
| 718 | 704 | }); |
| @@ -726,9 +712,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 7 unmodified lines | ||
| 726 | 712 | }); |
| 727 | 713 | |
| 728 | 714 | auto audioScriptingInterface = DependencyManager::set<AudioScriptingInterface>(); |
| 729 | − connect(audioThread, &QThread::started, audioIO.data(), &AudioClient::start); | |
| 730 | − connect(audioIO.data(), &AudioClient::destroyed, audioThread, &QThread::quit); | |
| 731 | − connect(audioThread, &QThread::finished, audioThread, &QThread::deleteLater); | |
| 732 | 715 | connect(audioIO.data(), &AudioClient::muteToggled, this, &Application::audioMuteToggled); |
| 733 | 716 | connect(audioIO.data(), &AudioClient::mutedByMixer, audioScriptingInterface.data(), &AudioScriptingInterface::mutedByMixer); |
| 734 | 717 | connect(audioIO.data(), &AudioClient::receivedFirstPacket, audioScriptingInterface.data(), &AudioScriptingInterface::receivedFirstPacket); |
| @@ -746,19 +729,14 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 11 unmodified lines | ||
| 746 | 729 | } |
| 747 | 730 | }); |
| 748 | 731 | |
| 749 | − audioThread->start(); | |
| 732 | + audioIO->startThread(); | |
| 750 | 733 | |
| 751 | 734 | ResourceManager::init(); |
| 752 | 735 | // Make sure we don't time out during slow operations at startup |
| 753 | 736 | updateHeartbeat(); |
| 754 | 737 | |
| 755 | 738 | // Setup MessagesClient |
| 756 | − auto messagesClient = DependencyManager::get<MessagesClient>(); | |
| 757 | − QThread* messagesThread = new QThread; | |
| 758 | − messagesThread->setObjectName("Messages Client Thread"); | |
| 759 | − messagesClient->moveToThread(messagesThread); | |
| 760 | − connect(messagesThread, &QThread::started, messagesClient.data(), &MessagesClient::init); | |
| 761 | − messagesThread->start(); | |
| 739 | + DependencyManager::get<MessagesClient>()->startThread(); | |
| 762 | 740 | |
| 763 | 741 | const DomainHandler& domainHandler = nodeList->getDomainHandler(); |
| 764 | 742 | |
| @@ -1678,12 +1656,7 @@ void Application::aboutToQuit() { · 913 unmodified lines | ||
| 1678 | 1656 | _autoSwitchDisplayModeSupportedHMDPlugin->endSession(); |
| 1679 | 1657 | } |
| 1680 | 1658 | // use the CloseEventSender via a QThread to send an event that says the user asked for the app to close |
| 1681 | − auto closeEventSender = DependencyManager::get<CloseEventSender>(); | |
| 1682 | − QThread* closureEventThread = new QThread(this); | |
| 1683 | − closeEventSender->moveToThread(closureEventThread); | |
| 1684 | − // sendQuitEventAsync will bail immediately if the UserActivityLogger is not enabled | |
| 1685 | − connect(closureEventThread, &QThread::started, closeEventSender.data(), &CloseEventSender::sendQuitEventAsync); | |
| 1686 | − closureEventThread->start(); | |
| 1659 | + DependencyManager::get<CloseEventSender>()->startThread(); | |
| 1687 | 1660 | |
| 1688 | 1661 | // Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown. |
| 1689 | 1662 | DependencyManager::get<OffscreenUi>()->hide("RunningScripts"); |
| @@ -1771,6 +1744,8 @@ void Application::cleanupBeforeQuit() { · 81 unmodified lines | ||
| 1771 | 1744 | // stop QML |
| 1772 | 1745 | DependencyManager::destroy<OffscreenUi>(); |
| 1773 | 1746 | |
| 1747 | + DependencyManager::destroy<OffscreenQmlSurfaceCache>(); | |
| 1748 | + | |
| 1774 | 1749 | if (_snapshotSoundInjector != nullptr) { |
| 1775 | 1750 | _snapshotSoundInjector->stop(); |
| 1776 | 1751 | } |
| @@ -1830,15 +1805,9 @@ Application::~Application() { · 53 unmodified lines | ||
| 1830 | 1805 | |
| 1831 | 1806 | ResourceManager::cleanup(); |
| 1832 | 1807 | |
| 1833 | − QThread* nodeThread = DependencyManager::get<NodeList>()->thread(); | |
| 1834 | − | |
| 1835 | 1808 | // remove the NodeList from the DependencyManager |
| 1836 | 1809 | DependencyManager::destroy<NodeList>(); |
| 1837 | 1810 | |
| 1838 | − // ask the node thread to quit and wait until it is done | |
| 1839 | − nodeThread->quit(); | |
| 1840 | − nodeThread->wait(); | |
| 1841 | − | |
| 1842 | 1811 | Leapmotion::destroy(); |
| 1843 | 1812 | |
| 1844 | 1813 | if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) { |