History

Merge branch 'master' of https://github.com/highfidelity/hifi into metavoxels

Andrzej Kapolka committed 12 years ago

Commit 61d97452 parents b5cba27 5e77f5615 files · +82 −93Browse files

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

Unified · Split

interface/src/Application.cpp+38−45
@@ -109,7 +109,7 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 108 unmodified lines
109109 _window(new QMainWindow(desktop())),
110110 _glWidget(new GLCanvas()),
111111 _nodeThread(new QThread(this)),
112− _datagramProcessor(new DatagramProcessor()),
112+ _datagramProcessor(),
113113 _frameCount(0),
114114 _fps(120.0f),
115115 _justStarted(true),
@@ -174,20 +174,20 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 58 unmodified lines
174174 listenPort = atoi(portStr);
175175 }
176176
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+
177183 // put the NodeList and datagram processing on the node thread
178184 NodeList* nodeList = NodeList::createInstance(NODE_TYPE_AGENT, listenPort);
179185
180186 nodeList->moveToThread(_nodeThread);
181− _datagramProcessor->moveToThread(_nodeThread);
187+ _datagramProcessor.moveToThread(_nodeThread);
182188
183189 // connect the DataProcessor processDatagrams slot to the QUDPSocket readyRead() signal
184− 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();
190+ connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams()));
191191
192192 // put the audio processing on a separate thread
193193 QThread* audioThread = new QThread(this);
@@ -231,12 +231,12 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 37 unmodified lines
231231 #endif
232232
233233 // tell the NodeList instance who to tell the domain server we care about
234− const char nodeTypesOfInterest[] = {NODE_TYPE_AUDIO_MIXER, NODE_TYPE_AVATAR_MIXER, NODE_TYPE_VOXEL_SERVER,
235− NODE_TYPE_PARTICLE_SERVER, NODE_TYPE_METAVOXEL_SERVER};
236− nodeList->setNodeTypesOfInterest(nodeTypesOfInterest, sizeof(nodeTypesOfInterest));
234+ nodeList->addSetOfNodeTypesToNodeInterestSet(QSet<NODE_TYPE>() << NODE_TYPE_AUDIO_MIXER << NODE_TYPE_AVATAR_MIXER
235+ << NODE_TYPE_VOXEL_SERVER << NODE_TYPE_PARTICLE_SERVER
236+ << NODE_TYPE_METAVOXEL_SERVER);
237237
238238 // move the silentNodeTimer to the _nodeThread
239− QTimer* silentNodeTimer = new QTimer(this);
239+ QTimer* silentNodeTimer = new QTimer();
240240 connect(silentNodeTimer, SIGNAL(timeout()), nodeList, SLOT(removeSilentNodes()));
241241 silentNodeTimer->moveToThread(_nodeThread);
242242 silentNodeTimer->start(NODE_SILENCE_THRESHOLD_USECS / 1000);
@@ -282,17 +282,35 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 39 unmodified lines
282282 Application::~Application() {
283283
284284 qInstallMessageHandler(NULL);
285−
285+
286286 // make sure we don't call the idle timer any more
287287 delete idleTimer;
288288
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+
289297 // 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+
293301 // ask the audio thread to quit and wait until it is done
294302 _audio.thread()->quit();
295303 _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+ }
296314
297315 storeSizeAndPosition();
298316 saveScripts();
@@ -377,9 +395,6 @@ void Application::initializeGL() { · 78 unmodified lines
377395 qDebug("Voxel parsing thread created.");
378396 }
379397
380− // call terminate before exiting
381− connect(this, SIGNAL(aboutToQuit()), SLOT(terminate()));
382−
383398 // call our timer function every second
384399 QTimer* timer = new QTimer(this);
385400 connect(timer, SIGNAL(timeout()), SLOT(timer()));
@@ -1328,11 +1343,11 @@ void Application::timer() { · 942 unmodified lines
13281343
13291344 _fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
13301345
1331− _packetsPerSecond = (float) _datagramProcessor->getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1332− _bytesPerSecond = (float) _datagramProcessor->getByteCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1346+ _packetsPerSecond = (float) _datagramProcessor.getPacketCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
1347+ _bytesPerSecond = (float) _datagramProcessor.getByteCount() / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
13331348 _frameCount = 0;
13341349
1335− _datagramProcessor->resetCounters();
1350+ _datagramProcessor.resetCounters();
13361351
13371352 gettimeofday(&_timerStart, NULL);
13381353
@@ -1411,28 +1426,6 @@ void Application::idle() { · 72 unmodified lines
14111426 }
14121427 }
14131428
1414−void Application::terminate() {
1415− // Close serial port
1416− // close(serial_fd);
1417−
1418− Menu::getInstance()->saveSettings();
1419− _rearMirrorTools->saveSettings(_settings);
1420− _settings->sync();
1421−
1422− // let the avatar mixer know we're out
1423− NodeList::getInstance()->sendKillNode(&NODE_TYPE_AVATAR_MIXER, 1);
1424−
1425− _voxelProcessor.terminate();
1426− _voxelHideShowThread.terminate();
1427− _voxelEditSender.terminate();
1428− _particleEditSender.terminate();
1429− if (_persistThread) {
1430− _persistThread->terminate();
1431− _persistThread->deleteLater();
1432− _persistThread = NULL;
1433− }
1434−}
1435−
14361429 void Application::checkBandwidthMeterClick() {
14371430 // ... to be called upon button release
14381431

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