Showing the changes to interface/src/Application.cpp (1 of 4 files). Show all
Unified · Split
| @@ -174,6 +174,12 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 173 unmodified lines | ||
| 174 | 174 | listenPort = atoi(portStr); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | + // start the nodeThread so its event loop is running | |
| 178 | + _nodeThread->start(); | |
| 179 | + | |
| 180 | + // make sure the node thread is given highest priority | |
| 181 | + _nodeThread->setPriority(QThread::TimeCriticalPriority); | |
| 182 | + | |
| 177 | 183 | // put the NodeList and datagram processing on the node thread |
| 178 | 184 | NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort); |
| 179 | 185 | |
| @@ -182,12 +188,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 2 unmodified lines | ||
| 182 | 188 | |
| 183 | 189 | // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal |
| 184 | 190 | connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), _datagramProcessor, SLOT(processDatagrams())); |
| 185 | − | |
| 186 | − // make sure the node thread is given highest priority | |
| 187 | − _nodeThread->setPriority(QThread::TimeCriticalPriority); | |
| 188 | − | |
| 189 | − // start the nodeThread so its event loop is running | |
| 190 | − _nodeThread->start(); | |
| 191 | 191 | |
| 192 | 192 | // put the audio processing on a separate thread |
| 193 | 193 | QThread* audioThread = new QThread(this); |
| @@ -236,7 +236,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 42 unmodified lines | ||
| 236 | 236 | nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest)); |
| 237 | 237 | |
| 238 | 238 | // move the silentNodeTimer to the _nodeThread |
| 239 | − QTimer* silentNodeTimer = new QTimer(this); | |
| 239 | + QTimer* silentNodeTimer = new QTimer(); | |
| 240 | 240 | connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes())); |
| 241 | 241 | silentNodeTimer->moveToThread(_nodeThread); |
| 242 | 242 | silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000); |
| @@ -282,17 +282,35 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 39 unmodified lines | ||
| 282 | 282 | Application::~Application() { |
| 283 | 283 | |
| 284 | 284 | qInstallMessageHandler(NULL); |
| 285 | − | |
| 285 | + | |
| 286 | 286 | // make sure we don't call the idle timer any more |
| 287 | 287 | delete idleTimer; |
| 288 | 288 | |
| 289 | + Menu::getInstance()->saveSettings(); | |
| 290 | + | |
| 291 | + _rearMirrorTools->saveSettings(_settings); | |
| 292 | + _settings->sync(); | |
| 293 | + | |
| 294 | + // let the avatar mixer know we're out | |
| 295 | + NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1); | |
| 296 | + | |
| 289 | 297 | // ask the datagram processing thread to quit and wait until it is done |
| 290 | − _nodeThread->thread()->quit(); | |
| 291 | − _nodeThread->thread()->wait(); | |
| 292 | − | |
| 298 | + _nodeThread->quit(); | |
| 299 | + _nodeThread->wait(); | |
| 300 | + | |
| 293 | 301 | // ask the audio thread to quit and wait until it is done |
| 294 | 302 | _audio.thread()->quit(); |
| 295 | 303 | _audio.thread()->wait(); |
| 304 | + | |
| 305 | + _voxelProcessor.terminate(); | |
| 306 | + _voxelHideShowThread.terminate(); | |
| 307 | + _voxelEditSender.terminate(); | |
| 308 | + _particleEditSender.terminate(); | |
| 309 | + if (_persistThread) { | |
| 310 | + _persistThread->terminate(); | |
| 311 | + _persistThread->deleteLater(); | |
| 312 | + _persistThread = NULL; | |
| 313 | + } | |
| 296 | 314 | |
| 297 | 315 | storeSizeAndPosition(); |
| 298 | 316 | saveScripts(); |
| @@ -377,9 +395,6 @@ void Application::initializeGL() { · 78 unmodified lines | ||
| 377 | 395 | qDebug("Voxel parsing thread created."); |
| 378 | 396 | } |
| 379 | 397 | |
| 380 | − // call terminate before exiting | |
| 381 | − connect(this, SIGNAL(aboutToQuit()), SLOT(terminate())); | |
| 382 | − | |
| 383 | 398 | // call our timer function every second |
| 384 | 399 | QTimer* timer = new QTimer(this); |
| 385 | 400 | connect(timer, SIGNAL(timeout()), SLOT(timer())); |
| @@ -1412,28 +1427,6 @@ void Application::idle() { · 1026 unmodified lines | ||
| 1412 | 1427 | } |
| 1413 | 1428 | } |
| 1414 | 1429 | |
| 1415 | −void Application::terminate() { | |
| 1416 | − // Close serial port | |
| 1417 | − // close(serial_fd); | |
| 1418 | − | |
| 1419 | − Menu::getInstance()->saveSettings(); | |
| 1420 | − _rearMirrorTools->saveSettings(_settings); | |
| 1421 | − _settings->sync(); | |
| 1422 | − | |
| 1423 | − // let the avatar mixer know we're out | |
| 1424 | − NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1); | |
| 1425 | − | |
| 1426 | − _voxelProcessor.terminate(); | |
| 1427 | − _voxelHideShowThread.terminate(); | |
| 1428 | − _voxelEditSender.terminate(); | |
| 1429 | − _particleEditSender.terminate(); | |
| 1430 | − if (_persistThread) { | |
| 1431 | − _persistThread->terminate(); | |
| 1432 | − _persistThread->deleteLater(); | |
| 1433 | − _persistThread = NULL; | |
| 1434 | − } | |
| 1435 | −} | |
| 1436 | − | |
| 1437 | 1430 | void Application::checkBandwidthMeterClick() { |
| 1438 | 1431 | // ... to be called upon button release |
| 1439 | 1432 | |