History

Merge branch 'master' of github.com:highfidelity/hifi into fix-head-puck-broken-eyes

Seth Alves committed 9 years ago

Commit 197fb622 parents ce4c3e1 759a87c52 files · +1068 −296Browse files

Showing the changes to interface/src/Application.cpp (1 of 52 files). Show all

Unified · Split

interface/src/Application.cpp+6−37
@@ -653,6 +653,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 652 unmodified lines
653653 Model::setAbstractViewStateInterface(this); // The model class will sometimes need to know view state details from us
654654
655655 auto nodeList = DependencyManager::get<NodeList>();
656+ nodeList->startThread();
656657
657658 // Set up a watchdog thread to intentionally crash the application on deadlocks
658659 _deadlockWatchdogThread = new DeadlockWatchdogThread();
@@ -678,25 +679,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 19 unmodified lines
678679
679680 updateHeartbeat();
680681
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−
689682 // setup a timer for domain-server check ins
690683 QTimer* domainCheckInTimer = new QTimer(nodeList.data());
691684 connect(domainCheckInTimer, &QTimer::timeout, nodeList.data(), &NodeList::sendDomainServerCheckIn);
692685 domainCheckInTimer->start(DOMAIN_SERVER_CHECK_IN_MSECS);
693686
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");
700687
701688 auto audioIO = DependencyManager::get<AudioClient>();
702689 audioIO->setPositionGetter([]{
@@ -712,7 +699,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 9 unmodified lines
712699 return myAvatar ? myAvatar->getOrientationForAudio() : Quaternions::IDENTITY;
713700 });
714701
715− audioIO->moveToThread(audioThread);
716702 recording::Frame::registerFrameHandler(AudioConstants::getAudioFrameName(), [=](recording::Frame::ConstPointer frame) {
717703 audioIO->handleRecordedAudioInput(frame->data);
718704 });
@@ -726,9 +712,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 7 unmodified lines
726712 });
727713
728714 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);
732715 connect(audioIO.data(), &AudioClient::muteToggled, this, &Application::audioMuteToggled);
733716 connect(audioIO.data(), &AudioClient::mutedByMixer, audioScriptingInterface.data(), &AudioScriptingInterface::mutedByMixer);
734717 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
746729 }
747730 });
748731
749− audioThread->start();
732+ audioIO->startThread();
750733
751734 ResourceManager::init();
752735 // Make sure we don't time out during slow operations at startup
753736 updateHeartbeat();
754737
755738 // 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();
762740
763741 const DomainHandler& domainHandler = nodeList->getDomainHandler();
764742
@@ -1678,12 +1656,7 @@ void Application::aboutToQuit() { · 913 unmodified lines
16781656 _autoSwitchDisplayModeSupportedHMDPlugin->endSession();
16791657 }
16801658 // 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();
16871660
16881661 // Hide Running Scripts dialog so that it gets destroyed in an orderly manner; prevents warnings at shutdown.
16891662 DependencyManager::get<OffscreenUi>()->hide("RunningScripts");
@@ -1771,6 +1744,8 @@ void Application::cleanupBeforeQuit() { · 81 unmodified lines
17711744 // stop QML
17721745 DependencyManager::destroy<OffscreenUi>();
17731746
1747+ DependencyManager::destroy<OffscreenQmlSurfaceCache>();
1748+
17741749 if (_snapshotSoundInjector != nullptr) {
17751750 _snapshotSoundInjector->stop();
17761751 }
@@ -1830,15 +1805,9 @@ Application::~Application() { · 53 unmodified lines
18301805
18311806 ResourceManager::cleanup();
18321807
1833− QThread* nodeThread = DependencyManager::get<NodeList>()->thread();
1834−
18351808 // remove the NodeList from the DependencyManager
18361809 DependencyManager::destroy<NodeList>();
18371810
1838− // ask the node thread to quit and wait until it is done
1839− nodeThread->quit();
1840− nodeThread->wait();
1841−
18421811 Leapmotion::destroy();
18431812
18441813 if (auto steamClient = PluginManager::getInstance()->getSteamClientPlugin()) {