History

merge upstream/master into andrew/inertia

Andrew Meadows committed 11 years ago

Commit 37be7252 parents c3b432c 511325857 files · +1353 −678Browse files

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

Unified · Split

interface/src/Application.cpp+29−26
@@ -328,7 +328,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 327 unmodified lines
328328 connect(&nodeList->getNodeSocket(), SIGNAL(readyRead()), &_datagramProcessor, SLOT(processDatagrams()));
329329
330330 // put the audio processing on a separate thread
331− QThread* audioThread = new QThread(this);
331+ QThread* audioThread = new QThread();
332332 audioThread->setObjectName("Audio Thread");
333333
334334 auto audioIO = DependencyManager::get<AudioClient>();
@@ -338,7 +338,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 3 unmodified lines
338338
339339 audioIO->moveToThread(audioThread);
340340 connect(audioThread, &QThread::started, audioIO.data(), &AudioClient::start);
341− connect(audioIO.data(), SIGNAL(muteToggled()), this, SLOT(audioMuteToggled()));
341+ connect(audioIO.data(), &AudioClient::destroyed, audioThread, &QThread::quit);
342+ connect(audioThread, &QThread::finished, audioThread, &QThread::deleteLater);
343+ connect(audioIO.data(), &AudioClient::muteToggled, this, &Application::audioMuteToggled);
342344
343345 audioThread->start();
344346
@@ -516,37 +518,40 @@ Application::Application(int& argc, char** argv, QElapsedTimer &startup_time) : · 171 unmodified lines
516518
517519 void Application::aboutToQuit() {
518520 _aboutToQuit = true;
521+
522+ cleanupBeforeQuit();
519523 }
520524
521−Application::~Application() {
522− // stop idle calls
523− delete idleTimer;
524−
525− // save settings
525+void Application::cleanupBeforeQuit() {
526526 QMetaObject::invokeMethod(&_settingsTimer, "stop", Qt::BlockingQueuedConnection);
527527 _settingsThread.quit();
528528 saveSettings();
529+
530+ // TODO: now that this is in cleanupBeforeQuit do we really need it to stop and force
531+ // an event loop to send the packet?
532+ UserActivityLogger::getInstance().close();
533+
534+ // stop the AudioClient
535+ QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(),
536+ "stop", Qt::BlockingQueuedConnection);
537+
538+ // destroy the AudioClient so it and its thread have a chance to go down safely
539+ DependencyManager::destroy<AudioClient>();
540+}
541+
542+Application::~Application() {
529543 _window->saveGeometry();
530544
545+ // make sure we don't call the idle timer any more
546+ delete idleTimer;
547+
531548 // let the avatar mixer know we're out
532549 MyAvatar::sendKillAvatar();
533550
534− // log activity (sends data over HTTP)
535− // NOTE: there is still an occasional crash in UserActivitiyLogger::close()
536− int DELAY_TIME = 1000;
537− UserActivityLogger::getInstance().close(DELAY_TIME);
538−
539551 // ask the datagram processing thread to quit and wait until it is done
540552 _nodeThread->quit();
541553 _nodeThread->wait();
542554
543− // kill audio
544− AudioScriptingInterface::getInstance().stopAllInjectors();
545− auto audioIO = DependencyManager::get<AudioClient>();
546− QMetaObject::invokeMethod(audioIO.data(), "stop", Qt::BlockingQueuedConnection);
547− audioIO->thread()->quit();
548− audioIO->thread()->wait();
549−
550555 _octreeProcessor.terminate();
551556 _entityEditSender.terminate();
552557
@@ -567,12 +572,6 @@ Application::~Application() { · 14 unmodified lines
567572 tree->unlock();
568573
569574 qInstallMessageHandler(NULL);
570−
571−#ifndef DEBUG
572− // At this point we return all memory to the operating system ASAP
573− // and don't worry about proper cleanup of global variables.
574− exit(0);
575−#endif
576575 }
577576
578577 void Application::initializeGL() {
@@ -2609,6 +2608,9 @@ const GLfloat WORLD_AMBIENT_COLOR[] = { 0.525f, 0.525f, 0.6f }; · 2030 unmodified lines
26092608 const GLfloat WORLD_DIFFUSE_COLOR[] = { 0.6f, 0.525f, 0.525f };
26102609 const GLfloat WORLD_SPECULAR_COLOR[] = { 0.94f, 0.94f, 0.737f, 1.0f };
26112610
2611+const glm::vec3 GLOBAL_LIGHT_COLOR = { 0.6f, 0.525f, 0.525f };
2612+const float GLOBAL_LIGHT_INTENSITY = 1.0f;
2613+
26122614 void Application::setupWorldLight() {
26132615
26142616 // Setup 3D lights (after the camera transform, so that they are positioned in world space)
@@ -2623,6 +2625,7 @@ void Application::setupWorldLight() { · 8 unmodified lines
26232625 glLightfv(GL_LIGHT0, GL_SPECULAR, WORLD_SPECULAR_COLOR);
26242626 glMaterialfv(GL_FRONT, GL_SPECULAR, WORLD_SPECULAR_COLOR);
26252627 glMateriali(GL_FRONT, GL_SHININESS, 96);
2628+
26262629 }
26272630
26282631 bool Application::shouldRenderMesh(float largestDimension, float distanceToCamera) {
@@ -2829,7 +2832,7 @@ void Application::displaySide(Camera& theCamera, bool selfAvatarOnly, RenderArgs · 200 unmodified lines
28292832
28302833 {
28312834 DependencyManager::get<DeferredLightingEffect>()->setAmbientLightMode(getRenderAmbientLight());
2832−
2835+ DependencyManager::get<DeferredLightingEffect>()->setGlobalLight(-getSunDirection(), GLOBAL_LIGHT_COLOR, GLOBAL_LIGHT_INTENSITY);
28332836 PROFILE_RANGE("DeferredLighting");
28342837 PerformanceTimer perfTimer("lighting");
28352838 DependencyManager::get<DeferredLightingEffect>()->render();

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