History

Revert "Revert "NOT MERGEABLE: graceful cleanup on Application dtor for NodeList""

This reverts commit 9269b2a0b2ae9d05abf721f32b3f3f91ad844b16.

Stephen Birarda committed 11 years ago

Commit 7bfc7471 parent 278813e6 files · +27 −34Browse files

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

Unified · Split

interface/src/Application.cpp+18−22
@@ -146,7 +146,6 @@ const qint64 MAXIMUM_CACHE_SIZE = 10 * BYTES_PER_GIGABYTES; // 10GB · 145 unmodified lines
146 146
147static QTimer* locationUpdateTimer = NULL;147static QTimer* locationUpdateTimer = NULL;
148static QTimer* balanceUpdateTimer = NULL;148static QTimer* balanceUpdateTimer = NULL;
149static QTimer* silentNodeTimer = NULL;
150static QTimer* identityPacketTimer = NULL;149static QTimer* identityPacketTimer = NULL;
151static QTimer* billboardPacketTimer = NULL;150static QTimer* billboardPacketTimer = NULL;
152static QTimer* checkFPStimer = NULL;151static QTimer* checkFPStimer = NULL;
@@ -258,7 +257,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 105 unmodified lines
258 _dependencyManagerIsSetup(setupEssentials(argc, argv)),257 _dependencyManagerIsSetup(setupEssentials(argc, argv)),
259 _window(new MainWindow(desktop())),258 _window(new MainWindow(desktop())),
260 _toolWindow(NULL),259 _toolWindow(NULL),
261 _nodeThread(new QThread(this)),
262 _datagramProcessor(),260 _datagramProcessor(),
263 _undoStack(),261 _undoStack(),
264 _undoStackScriptingInterface(&_undoStack),262 _undoStackScriptingInterface(&_undoStack),
@@ -329,18 +327,20 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 64 unmodified lines
329 _runningScriptsWidget = new RunningScriptsWidget(_window);327 _runningScriptsWidget = new RunningScriptsWidget(_window);
330 328
331 // start the nodeThread so its event loop is running329 // start the nodeThread so its event loop is running
332 _nodeThread->setObjectName("Datagram Processor Thread");330 QThread* nodeThread = new QThread(this);
333 _nodeThread->start();331 nodeThread->setObjectName("Datagram Processor Thread");
332 nodeThread->start();
334 333
335 // make sure the node thread is given highest priority334 // make sure the node thread is given highest priority
336 _nodeThread->setPriority(QThread::TimeCriticalPriority);335 nodeThread->setPriority(QThread::TimeCriticalPriority);
336
337 _datagramProcessor = new DatagramProcessor(nodeList.data());
337 338
338 // put the NodeList and datagram processing on the node thread339 // put the NodeList and datagram processing on the node thread
339 nodeList->moveToThread(_nodeThread);340 nodeList->moveToThread(nodeThread);
340 _datagramProcessor.moveToThread(_nodeThread);
341 341
342 // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal342 // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal
343 connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams()));343 connect(&nodeList->getNodeSocket(), &QUdpSocket::readyRead, _datagramProcessor, &DatagramProcessor::processDatagrams);
344 344
345 // put the audio processing on a separate thread345 // put the audio processing on a separate thread
346 QThread* audioThread = new QThread();346 QThread* audioThread = new QThread();
@@ -427,12 +427,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 80 unmodified lines
427 // connect to the packet sent signal of the _entityEditSender427 // connect to the packet sent signal of the _entityEditSender
428 connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent);428 connect(&_entityEditSender, &EntityEditPacketSender::packetSent, this, &Application::packetSent);
429 429
430 // move the silentNodeTimer to the _nodeThread
431 silentNodeTimer = new QTimer();
432 connect(silentNodeTimer, SIGNAL(timeout()), nodeList.data(), SLOT(removeSilentNodes()));
433 silentNodeTimer->start(NODE_SILENCE_THRESHOLD_MSECS);
434 silentNodeTimer->moveToThread(_nodeThread);
435
436 // send the identity packet for our avatar each second to our avatar mixer430 // send the identity packet for our avatar each second to our avatar mixer
437 identityPacketTimer = new QTimer();431 identityPacketTimer = new QTimer();
438 connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket);432 connect(identityPacketTimer, &QTimer::timeout, _myAvatar, &MyAvatar::sendIdentityPacket);
@@ -547,7 +541,7 @@ void Application::aboutToQuit() { · 108 unmodified lines
547}541}
548 542
549void Application::cleanupBeforeQuit() {543void Application::cleanupBeforeQuit() {
550 _datagramProcessor.shutdown(); // tell the datagram processor we're shutting down, so it can short circuit544 _datagramProcessor->shutdown(); // tell the datagram processor we're shutting down, so it can short circuit
551 _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts545 _entities.shutdown(); // tell the entities system we're shutting down, so it will stop running scripts
552 ScriptEngine::stopAllScripts(this); // stop all currently running global scripts546 ScriptEngine::stopAllScripts(this); // stop all currently running global scripts
553 547
@@ -555,7 +549,6 @@ void Application::cleanupBeforeQuit() { · 1 unmodified line
555 // depending on what thread they run in549 // depending on what thread they run in
556 locationUpdateTimer->stop();550 locationUpdateTimer->stop();
557 balanceUpdateTimer->stop();551 balanceUpdateTimer->stop();
558 QMetaObject::invokeMethod(silentNodeTimer, "stop", Qt::BlockingQueuedConnection);
559 identityPacketTimer->stop();552 identityPacketTimer->stop();
560 billboardPacketTimer->stop();553 billboardPacketTimer->stop();
561 checkFPStimer->stop();554 checkFPStimer->stop();
@@ -565,7 +558,6 @@ void Application::cleanupBeforeQuit() { · 3 unmodified lines
565 // and then delete those that got created by "new"558 // and then delete those that got created by "new"
566 delete locationUpdateTimer;559 delete locationUpdateTimer;
567 delete balanceUpdateTimer;560 delete balanceUpdateTimer;
568 delete silentNodeTimer;
569 delete identityPacketTimer;561 delete identityPacketTimer;
570 delete billboardPacketTimer;562 delete billboardPacketTimer;
571 delete checkFPStimer;563 delete checkFPStimer;
@@ -597,10 +589,6 @@ Application::~Application() { · 25 unmodified lines
597 tree->lockForWrite();589 tree->lockForWrite();
598 _entities.getTree()->setSimulation(NULL);590 _entities.getTree()->setSimulation(NULL);
599 tree->unlock();591 tree->unlock();
600
601 // ask the datagram processing thread to quit and wait until it is done
602 _nodeThread->quit();
603 _nodeThread->wait();
604 592
605 _octreeProcessor.terminate();593 _octreeProcessor.terminate();
606 _entityEditSender.terminate();594 _entityEditSender.terminate();
@@ -620,6 +608,14 @@ Application::~Application() { · 13 unmodified lines
620 DependencyManager::destroy<GeometryCache>();608 DependencyManager::destroy<GeometryCache>();
621 //DependencyManager::destroy<ScriptCache>();609 //DependencyManager::destroy<ScriptCache>();
622 DependencyManager::destroy<SoundCache>();610 DependencyManager::destroy<SoundCache>();
611
612 auto nodeList = DependencyManager::get<NodeList>();
613 QThread* nodeThread = nodeList->thread();
614 nodeList->deleteLater();
615
616 // ask the node thread to quit and wait until it is done
617 nodeThread->quit();
618 nodeThread->wait();
623 619
624 qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages620 qInstallMessageHandler(NULL); // NOTE: Do this as late as possible so we continue to get our log messages
625}621}
@@ -1498,7 +1494,7 @@ void Application::checkFPS() { · 872 unmodified lines
1498 1494
1499 _fps = (float)_frameCount / diffTime;1495 _fps = (float)_frameCount / diffTime;
1500 _frameCount = 0;1496 _frameCount = 0;
1501 _datagramProcessor.resetCounters();1497 _datagramProcessor->resetCounters();
1502 _timerStart.start();1498 _timerStart.start();
1503 1499
1504 // ask the node list to check in with the domain server1500 // ask the node list to check in with the domain server

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t