History

trying to fix dependency shutdown

SamGondelman committed 8 years ago

Commit 79548651 parent 01c4b5716 files · +159 −190Browse files

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

Unified · Split

interface/src/Application.cpp+125−127
@@ -1138,33 +1138,34 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 1137 unmodified lines
1138 domainCheckInTimer->deleteLater();1138 domainCheckInTimer->deleteLater();
1139 });1139 });
1140 1140
1141 {
1142 auto audioIO = DependencyManager::get<AudioClient>().data();
1143 audioIO->setPositionGetter([] {
1144 auto avatarManager = DependencyManager::get<AvatarManager>();
1145 auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;
1141 1146
1142 auto audioIO = DependencyManager::get<AudioClient>();1147 return myAvatar ? myAvatar->getPositionForAudio() : Vectors::ZERO;
1143 audioIO->setPositionGetter([]{1148 });
1144 auto avatarManager = DependencyManager::get<AvatarManager>();1149 audioIO->setOrientationGetter([] {
1145 auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;1150 auto avatarManager = DependencyManager::get<AvatarManager>();
1146 1151 auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;
1147 return myAvatar ? myAvatar->getPositionForAudio() : Vectors::ZERO;
1148 });
1149 audioIO->setOrientationGetter([]{
1150 auto avatarManager = DependencyManager::get<AvatarManager>();
1151 auto myAvatar = avatarManager ? avatarManager->getMyAvatar() : nullptr;
1152 1152
1153 return myAvatar ? myAvatar->getOrientationForAudio() : Quaternions::IDENTITY;1153 return myAvatar ? myAvatar->getOrientationForAudio() : Quaternions::IDENTITY;
1154 });1154 });
1155 1155
1156 recording::Frame::registerFrameHandler(AudioConstants::getAudioFrameName(), [=](recording::Frame::ConstPointer frame) {1156 recording::Frame::registerFrameHandler(AudioConstants::getAudioFrameName(), [=](recording::Frame::ConstPointer frame) {
1157 audioIO->handleRecordedAudioInput(frame->data);1157 audioIO->handleRecordedAudioInput(frame->data);
1158 });1158 });
1159 1159
1160 connect(audioIO.data(), &AudioClient::inputReceived, [](const QByteArray& audio){1160 connect(audioIO, &AudioClient::inputReceived, [](const QByteArray& audio) {
1161 static auto recorder = DependencyManager::get<recording::Recorder>();1161 static auto recorder = DependencyManager::get<recording::Recorder>();
1162 if (recorder->isRecording()) {1162 if (recorder->isRecording()) {
1163 static const recording::FrameType AUDIO_FRAME_TYPE = recording::Frame::registerFrameType(AudioConstants::getAudioFrameName());1163 static const recording::FrameType AUDIO_FRAME_TYPE = recording::Frame::registerFrameType(AudioConstants::getAudioFrameName());
1164 recorder->recordFrame(AUDIO_FRAME_TYPE, audio);1164 recorder->recordFrame(AUDIO_FRAME_TYPE, audio);
1165 }1165 }
1166 });1166 });
1167 audioIO->startThread();1167 audioIO->startThread();
1168 }
1168 1169
1169 // Make sure we don't time out during slow operations at startup1170 // Make sure we don't time out during slow operations at startup
1170 updateHeartbeat();1171 updateHeartbeat();
@@ -1263,27 +1264,29 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 92 unmodified lines
1263 // Inititalize sample before registering1264 // Inititalize sample before registering
1264 _sampleSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/sample.wav"));1265 _sampleSound = DependencyManager::get<SoundCache>()->getSound(PathUtils::resourcesUrl("sounds/sample.wav"));
1265 1266
1266 auto scriptEngines = DependencyManager::get<ScriptEngines>().data();1267 {
1267 scriptEngines->registerScriptInitializer([this](ScriptEnginePointer engine){1268 auto scriptEngines = DependencyManager::get<ScriptEngines>().data();
1268 registerScriptEngineWithApplicationServices(engine);1269 scriptEngines->registerScriptInitializer([this](ScriptEnginePointer engine) {
1269 });1270 registerScriptEngineWithApplicationServices(engine);
1271 });
1270 1272
1271 connect(scriptEngines, &ScriptEngines::scriptCountChanged, scriptEngines, [this] {1273 connect(scriptEngines, &ScriptEngines::scriptCountChanged, this, [this] {
1272 auto scriptEngines = DependencyManager::get<ScriptEngines>();1274 auto scriptEngines = DependencyManager::get<ScriptEngines>();
1273 if (scriptEngines->getRunningScripts().isEmpty()) {1275 if (scriptEngines->getRunningScripts().isEmpty()) {
1274 getMyAvatar()->clearScriptableSettings();1276 getMyAvatar()->clearScriptableSettings();
1275 }1277 }
1276 }, Qt::QueuedConnection);1278 }, Qt::QueuedConnection);
1277 1279
1278 connect(scriptEngines, &ScriptEngines::scriptsReloading, scriptEngines, [this] {1280 connect(scriptEngines, &ScriptEngines::scriptsReloading, this, [this] {
1279 getEntities()->reloadEntityScripts();1281 getEntities()->reloadEntityScripts();
1280 loadAvatarScripts(getMyAvatar()->getScriptUrls());1282 loadAvatarScripts(getMyAvatar()->getScriptUrls());
1281 }, Qt::QueuedConnection);1283 }, Qt::QueuedConnection);
1282 1284
1283 connect(scriptEngines, &ScriptEngines::scriptLoadError,1285 connect(scriptEngines, &ScriptEngines::scriptLoadError,
1284 scriptEngines, [](const QString& filename, const QString& error){1286 this, [](const QString& filename, const QString& error) {
1285 OffscreenUi::asyncWarning(nullptr, "Error Loading Script", filename + " failed to load.");1287 OffscreenUi::asyncWarning(nullptr, "Error Loading Script", filename + " failed to load.");
1286 }, Qt::QueuedConnection);1288 }, Qt::QueuedConnection);
1289 }
1287 1290
1288#ifdef _WIN321291#ifdef _WIN32
1289 WSADATA WsaData;1292 WSADATA WsaData;
@@ -1353,10 +1356,11 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 63 unmodified lines
1353 // so we defer the setup of the `scripting::Audio` class until this point1356 // so we defer the setup of the `scripting::Audio` class until this point
1354 {1357 {
1355 auto audioScriptingInterface = DependencyManager::set<AudioScriptingInterface, scripting::Audio>();1358 auto audioScriptingInterface = DependencyManager::set<AudioScriptingInterface, scripting::Audio>();
1356 connect(audioIO.data(), &AudioClient::mutedByMixer, audioScriptingInterface.data(), &AudioScriptingInterface::mutedByMixer);1359 auto audioIO = DependencyManager::get<AudioClient>().data();
1357 connect(audioIO.data(), &AudioClient::receivedFirstPacket, audioScriptingInterface.data(), &AudioScriptingInterface::receivedFirstPacket);1360 connect(audioIO, &AudioClient::mutedByMixer, audioScriptingInterface.data(), &AudioScriptingInterface::mutedByMixer);
1358 connect(audioIO.data(), &AudioClient::disconnected, audioScriptingInterface.data(), &AudioScriptingInterface::disconnected);1361 connect(audioIO, &AudioClient::receivedFirstPacket, audioScriptingInterface.data(), &AudioScriptingInterface::receivedFirstPacket);
1359 connect(audioIO.data(), &AudioClient::muteEnvironmentRequested, [](glm::vec3 position, float radius) {1362 connect(audioIO, &AudioClient::disconnected, audioScriptingInterface.data(), &AudioScriptingInterface::disconnected);
1363 connect(audioIO, &AudioClient::muteEnvironmentRequested, [](glm::vec3 position, float radius) {
1360 auto audioClient = DependencyManager::get<AudioClient>();1364 auto audioClient = DependencyManager::get<AudioClient>();
1361 auto audioScriptingInterface = DependencyManager::get<AudioScriptingInterface>();1365 auto audioScriptingInterface = DependencyManager::get<AudioScriptingInterface>();
1362 auto myAvatarPosition = DependencyManager::get<AvatarManager>()->getMyAvatar()->getWorldPosition();1366 auto myAvatarPosition = DependencyManager::get<AvatarManager>()->getMyAvatar()->getWorldPosition();
@@ -1688,23 +1692,26 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 325 unmodified lines
1688 userInputMapper->registerDevice(_touchscreenVirtualPadDevice->getInputDevice());1692 userInputMapper->registerDevice(_touchscreenVirtualPadDevice->getInputDevice());
1689 }1693 }
1690 1694
1691 // this will force the model the look at the correct directory (weird order of operations issue)1695 {
1692 scriptEngines->reloadLocalFiles();1696 auto scriptEngines = DependencyManager::get<ScriptEngines>().data();
1693 1697 // this will force the model the look at the correct directory (weird order of operations issue)
1694 // do this as late as possible so that all required subsystems are initialized1698 scriptEngines->reloadLocalFiles();
1695 // If we've overridden the default scripts location, just load default scripts1699
1696 // otherwise, load 'em all1700 // do this as late as possible so that all required subsystems are initialized
1697 1701 // If we've overridden the default scripts location, just load default scripts
1698 // we just want to see if --scripts was set, we've already parsed it and done1702 // otherwise, load 'em all
1699 // the change in PathUtils. Rather than pass that in the constructor, lets just1703
1700 // look (this could be debated)1704 // we just want to see if --scripts was set, we've already parsed it and done
1701 QString scriptsSwitch = QString("--").append(SCRIPTS_SWITCH);1705 // the change in PathUtils. Rather than pass that in the constructor, lets just
1702 QDir defaultScriptsLocation(getCmdOption(argc, constArgv, scriptsSwitch.toStdString().c_str()));1706 // look (this could be debated)
1703 if (!defaultScriptsLocation.exists()) {1707 QString scriptsSwitch = QString("--").append(SCRIPTS_SWITCH);
1704 scriptEngines->loadDefaultScripts();1708 QDir defaultScriptsLocation(getCmdOption(argc, constArgv, scriptsSwitch.toStdString().c_str()));
1705 scriptEngines->defaultScriptsLocationOverridden(true);1709 if (!defaultScriptsLocation.exists()) {
1706 } else {1710 scriptEngines->loadDefaultScripts();
1707 scriptEngines->loadScripts();1711 scriptEngines->defaultScriptsLocationOverridden(true);
1712 } else {
1713 scriptEngines->loadScripts();
1714 }
1708 }1715 }
1709 1716
1710 // Make sure we don't time out during slow operations at startup1717 // Make sure we don't time out during slow operations at startup
@@ -1754,13 +1761,16 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 43 unmodified lines
1754 cameraMenuChanged();1761 cameraMenuChanged();
1755 }1762 }
1756 1763
1757 // set the local loopback interface for local sounds1764 {
1758 AudioInjector::setLocalAudioInterface(audioIO.data());1765 auto audioIO = DependencyManager::get<AudioClient>().data();
1759 auto audioScriptingInterface = DependencyManager::get<AudioScriptingInterface>();1766 // set the local loopback interface for local sounds
1760 audioScriptingInterface->setLocalAudioInterface(audioIO.data());1767 AudioInjector::setLocalAudioInterface(audioIO);
1761 connect(audioIO.data(), &AudioClient::noiseGateOpened, audioScriptingInterface.data(), &AudioScriptingInterface::noiseGateOpened);1768 auto audioScriptingInterface = DependencyManager::get<AudioScriptingInterface>();
1762 connect(audioIO.data(), &AudioClient::noiseGateClosed, audioScriptingInterface.data(), &AudioScriptingInterface::noiseGateClosed);1769 audioScriptingInterface->setLocalAudioInterface(audioIO);
1763 connect(audioIO.data(), &AudioClient::inputReceived, audioScriptingInterface.data(), &AudioScriptingInterface::inputReceived);1770 connect(audioIO, &AudioClient::noiseGateOpened, audioScriptingInterface.data(), &AudioScriptingInterface::noiseGateOpened);
1771 connect(audioIO, &AudioClient::noiseGateClosed, audioScriptingInterface.data(), &AudioScriptingInterface::noiseGateClosed);
1772 connect(audioIO, &AudioClient::inputReceived, audioScriptingInterface.data(), &AudioScriptingInterface::inputReceived);
1773 }
1764 1774
1765 this->installEventFilter(this);1775 this->installEventFilter(this);
1766 1776
@@ -2174,11 +2184,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo · 407 unmodified lines
2174 QVariant testProperty = property(hifi::properties::TEST);2184 QVariant testProperty = property(hifi::properties::TEST);
2175 qDebug() << testProperty;2185 qDebug() << testProperty;
2176 if (testProperty.isValid()) {2186 if (testProperty.isValid()) {
2177 auto scriptEngines = DependencyManager::get<ScriptEngines>();
2178 const auto testScript = property(hifi::properties::TEST).toUrl();2187 const auto testScript = property(hifi::properties::TEST).toUrl();
2179 2188
2180 // Set last parameter to exit interface when the test script finishes, if so requested2189 // Set last parameter to exit interface when the test script finishes, if so requested
2181 scriptEngines->loadScript(testScript, false, false, false, false, quitWhenFinished);2190 DependencyManager::get<ScriptEngines>()->loadScript(testScript, false, false, false, false, quitWhenFinished);
2182 2191
2183 // This is done so we don't get a "connection time-out" message when we haven't passed in a URL.2192 // This is done so we don't get a "connection time-out" message when we haven't passed in a URL.
2184 if (arguments().contains("--url")) {2193 if (arguments().contains("--url")) {
@@ -2456,6 +2465,15 @@ void Application::cleanupBeforeQuit() { · 271 unmodified lines
2456 // Clear any queued processing (I/O, FBX/OBJ/Texture parsing)2465 // Clear any queued processing (I/O, FBX/OBJ/Texture parsing)
2457 QThreadPool::globalInstance()->clear();2466 QThreadPool::globalInstance()->clear();
2458 2467
2468 // These classes hold ScriptEnginePointers, so they must be destroyed before ScriptEngines
2469 {
2470 DependencyManager::destroy<RecordingScriptingInterface>();
2471 DependencyManager::destroy<StandAloneJSConsole>();
2472 EntityTreePointer tree = getEntities()->getTree();
2473 tree->setSimulation(nullptr);
2474 DependencyManager::destroy<EntityTreeRenderer>();
2475 }
2476
2459 DependencyManager::get<ScriptEngines>()->shutdownScripting(); // stop all currently running global scripts2477 DependencyManager::get<ScriptEngines>()->shutdownScripting(); // stop all currently running global scripts
2460 DependencyManager::destroy<ScriptEngines>();2478 DependencyManager::destroy<ScriptEngines>();
2461 2479
@@ -2493,6 +2511,8 @@ void Application::cleanupBeforeQuit() { · 31 unmodified lines
2493 DependencyManager::destroy<EyeTracker>();2511 DependencyManager::destroy<EyeTracker>();
2494#endif2512#endif
2495 2513
2514 DependencyManager::destroy<ContextOverlayInterface>(); // Must be destroyed before TabletScriptingInterface
2515
2496 // stop QML2516 // stop QML
2497 DependencyManager::destroy<TabletScriptingInterface>();2517 DependencyManager::destroy<TabletScriptingInterface>();
2498 DependencyManager::destroy<ToolbarScriptingInterface>();2518 DependencyManager::destroy<ToolbarScriptingInterface>();
@@ -2504,10 +2524,6 @@ void Application::cleanupBeforeQuit() { · 5 unmodified lines
2504 _snapshotSoundInjector->stop();2524 _snapshotSoundInjector->stop();
2505 }2525 }
2506 2526
2507 // FIXME: something else is holding a reference to AudioClient,
2508 // so it must be explicitly synchronously stopped here
2509 DependencyManager::get<AudioClient>()->cleanupBeforeQuit();
2510
2511 // destroy Audio so it and its threads have a chance to go down safely2527 // destroy Audio so it and its threads have a chance to go down safely
2512 // this must happen after QML, as there are unexplained audio crashes originating in qtwebengine2528 // this must happen after QML, as there are unexplained audio crashes originating in qtwebengine
2513 DependencyManager::destroy<AudioClient>();2529 DependencyManager::destroy<AudioClient>();
@@ -2547,9 +2563,6 @@ Application::~Application() { · 33 unmodified lines
2547 _entityClipboard->eraseAllOctreeElements();2563 _entityClipboard->eraseAllOctreeElements();
2548 _entityClipboard.reset();2564 _entityClipboard.reset();
2549 2565
2550 EntityTreePointer tree = getEntities()->getTree();
2551 tree->setSimulation(nullptr);
2552
2553 _octreeProcessor.terminate();2566 _octreeProcessor.terminate();
2554 _entityEditSender.terminate();2567 _entityEditSender.terminate();
2555 2568
@@ -3239,8 +3252,7 @@ void Application::showHelp() { · 683 unmodified lines
3239 QUrlQuery queryString;3252 QUrlQuery queryString;
3240 queryString.addQueryItem("handControllerName", handControllerName);3253 queryString.addQueryItem("handControllerName", handControllerName);
3241 queryString.addQueryItem("defaultTab", defaultTab);3254 queryString.addQueryItem("defaultTab", defaultTab);
3242 auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();3255 TabletProxy* tablet = dynamic_cast<TabletProxy*>(DependencyManager::get<TabletScriptingInterface>()->getTablet(SYSTEM_TABLET));
3243 TabletProxy* tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet(SYSTEM_TABLET));
3244 tablet->gotoWebScreen(PathUtils::resourcesUrl() + INFO_HELP_PATH + "?" + queryString.toString());3256 tablet->gotoWebScreen(PathUtils::resourcesUrl() + INFO_HELP_PATH + "?" + queryString.toString());
3245 DependencyManager::get<HMDScriptingInterface>()->openTablet();3257 DependencyManager::get<HMDScriptingInterface>()->openTablet();
3246 //InfoView::show(INFO_HELP_PATH, false, queryString.toString());3258 //InfoView::show(INFO_HELP_PATH, false, queryString.toString());
@@ -3545,6 +3557,10 @@ static void dumpEventQueue(QThread* thread) { · 298 unmodified lines
3545 3557
3546bool Application::event(QEvent* event) {3558bool Application::event(QEvent* event) {
3547 3559
3560 if (_aboutToQuit) {
3561 return false;
3562 }
3563
3548 if (!Menu::getInstance()) {3564 if (!Menu::getInstance()) {
3549 return false;3565 return false;
3550 }3566 }
@@ -3937,10 +3953,6 @@ void Application::maybeToggleMenuVisible(QMouseEvent* event) const { · 386 unmodified lines
3937void Application::mouseMoveEvent(QMouseEvent* event) {3953void Application::mouseMoveEvent(QMouseEvent* event) {
3938 PROFILE_RANGE(app_input_mouse, __FUNCTION__);3954 PROFILE_RANGE(app_input_mouse, __FUNCTION__);
3939 3955
3940 if (_aboutToQuit) {
3941 return;
3942 }
3943
3944 maybeToggleMenuVisible(event);3956 maybeToggleMenuVisible(event);
3945 3957
3946 auto& compositor = getApplicationCompositor();3958 auto& compositor = getApplicationCompositor();
@@ -4005,11 +4017,9 @@ void Application::mousePressEvent(QMouseEvent* event) { · 58 unmodified lines
4005 event->screenPos(), event->button(),4017 event->screenPos(), event->button(),
4006 event->buttons(), event->modifiers());4018 event->buttons(), event->modifiers());
4007 4019
4008 if (!_aboutToQuit) {4020 getOverlays().mousePressEvent(&mappedEvent);
4009 getOverlays().mousePressEvent(&mappedEvent);4021 if (!_controllerScriptingInterface->areEntityClicksCaptured()) {
4010 if (!_controllerScriptingInterface->areEntityClicksCaptured()) {4022 getEntities()->mousePressEvent(&mappedEvent);
4011 getEntities()->mousePressEvent(&mappedEvent);
4012 }
4013 }4023 }
4014 4024
4015 _controllerScriptingInterface->emitMousePressEvent(&mappedEvent); // send events to any registered scripts4025 _controllerScriptingInterface->emitMousePressEvent(&mappedEvent); // send events to any registered scripts
@@ -4035,14 +4045,11 @@ void Application::mouseDoublePressEvent(QMouseEvent* event) { · 19 unmodified lines
4035 event->screenPos(), event->button(),4045 event->screenPos(), event->button(),
4036 event->buttons(), event->modifiers());4046 event->buttons(), event->modifiers());
4037 4047
4038 if (!_aboutToQuit) {4048 getOverlays().mouseDoublePressEvent(&mappedEvent);
4039 getOverlays().mouseDoublePressEvent(&mappedEvent);4049 if (!_controllerScriptingInterface->areEntityClicksCaptured()) {
4040 if (!_controllerScriptingInterface->areEntityClicksCaptured()) {4050 getEntities()->mouseDoublePressEvent(&mappedEvent);
4041 getEntities()->mouseDoublePressEvent(&mappedEvent);
4042 }
4043 }4051 }
4044 4052
4045
4046 // if one of our scripts have asked to capture this event, then stop processing it4053 // if one of our scripts have asked to capture this event, then stop processing it
4047 if (_controllerScriptingInterface->isMouseCaptured()) {4054 if (_controllerScriptingInterface->isMouseCaptured()) {
4048 return;4055 return;
@@ -4061,10 +4068,8 @@ void Application::mouseReleaseEvent(QMouseEvent* event) { · 12 unmodified lines
4061 event->screenPos(), event->button(),4068 event->screenPos(), event->button(),
4062 event->buttons(), event->modifiers());4069 event->buttons(), event->modifiers());
4063 4070
4064 if (!_aboutToQuit) {4071 getOverlays().mouseReleaseEvent(&mappedEvent);
4065 getOverlays().mouseReleaseEvent(&mappedEvent);4072 getEntities()->mouseReleaseEvent(&mappedEvent);
4066 getEntities()->mouseReleaseEvent(&mappedEvent);
4067 }
4068 4073
4069 _controllerScriptingInterface->emitMouseReleaseEvent(&mappedEvent); // send events to any registered scripts4074 _controllerScriptingInterface->emitMouseReleaseEvent(&mappedEvent); // send events to any registered scripts
4070 4075
@@ -4215,7 +4220,6 @@ bool Application::shouldPaint() const { · 144 unmodified lines
4215 return false;4220 return false;
4216 }4221 }
4217 4222
4218
4219 auto displayPlugin = getActiveDisplayPlugin();4223 auto displayPlugin = getActiveDisplayPlugin();
4220 4224
4221#ifdef DEBUG_PAINT_DELAY4225#ifdef DEBUG_PAINT_DELAY
@@ -5439,6 +5443,10 @@ static bool domainLoadingInProgress = false; · 1217 unmodified lines
5439void Application::update(float deltaTime) {5443void Application::update(float deltaTime) {
5440 PROFILE_RANGE_EX(app, __FUNCTION__, 0xffff0000, (uint64_t)_renderFrameCount + 1);5444 PROFILE_RANGE_EX(app, __FUNCTION__, 0xffff0000, (uint64_t)_renderFrameCount + 1);
5441 5445
5446 if (_aboutToQuit) {
5447 return;
5448 }
5449
5442 if (!_physicsEnabled) {5450 if (!_physicsEnabled) {
5443 if (!domainLoadingInProgress) {5451 if (!domainLoadingInProgress) {
5444 PROFILE_ASYNC_BEGIN(app, "Scene Loading", "");5452 PROFILE_ASYNC_BEGIN(app, "Scene Loading", "");
@@ -5705,15 +5713,13 @@ void Application::update(float deltaTime) { · 260 unmodified lines
5705 _entitySimulation->handleDeactivatedMotionStates(deactivations);5713 _entitySimulation->handleDeactivatedMotionStates(deactivations);
5706 });5714 });
5707 5715
5708 if (!_aboutToQuit) {5716 // handleCollisionEvents() AFTER handleChangedMotionStates()
5709 // handleCollisionEvents() AFTER handleChangedMotionStates()5717 {
5710 {5718 PROFILE_RANGE(simulation_physics, "CollisionEvents");
5711 PROFILE_RANGE(simulation_physics, "CollisionEvents");5719 avatarManager->handleCollisionEvents(collisionEvents);
5712 avatarManager->handleCollisionEvents(collisionEvents);5720 // Collision events (and their scripts) must not be handled when we're locked, above. (That would risk
5713 // Collision events (and their scripts) must not be handled when we're locked, above. (That would risk5721 // deadlock.)
5714 // deadlock.)5722 _entitySimulation->handleCollisionEvents(collisionEvents);
5715 _entitySimulation->handleCollisionEvents(collisionEvents);
5716 }
5717 }5723 }
5718 5724
5719 {5725 {
@@ -5731,11 +5737,9 @@ void Application::update(float deltaTime) { · 11 unmodified lines
5731 }5737 }
5732 auto t4 = std::chrono::high_resolution_clock::now();5738 auto t4 = std::chrono::high_resolution_clock::now();
5733 5739
5734 if (!_aboutToQuit) {5740 // NOTE: the getEntities()->update() call below will wait for lock
5735 // NOTE: the getEntities()->update() call below will wait for lock5741 // and will provide non-physical entity motion
5736 // and will provide non-physical entity motion5742 getEntities()->update(true); // update the models...
5737 getEntities()->update(true); // update the models...
5738 }
5739 5743
5740 auto t5 = std::chrono::high_resolution_clock::now();5744 auto t5 = std::chrono::high_resolution_clock::now();
5741 5745
@@ -6639,16 +6643,12 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEnginePointe · 897 unmodified lines
6639 DependencyManager::get<PickScriptingInterface>()->registerMetaTypes(scriptEngine.data());6643 DependencyManager::get<PickScriptingInterface>()->registerMetaTypes(scriptEngine.data());
6640 6644
6641 // connect this script engines printedMessage signal to the global ScriptEngines these various messages6645 // connect this script engines printedMessage signal to the global ScriptEngines these various messages
6642 connect(scriptEngine.data(), &ScriptEngine::printedMessage,6646 auto scriptEngines = DependencyManager::get<ScriptEngines>().data();
6643 DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onPrintedMessage);6647 connect(scriptEngine.data(), &ScriptEngine::printedMessage, scriptEngines, &ScriptEngines::onPrintedMessage);
6644 connect(scriptEngine.data(), &ScriptEngine::errorMessage,6648 connect(scriptEngine.data(), &ScriptEngine::errorMessage, scriptEngines, &ScriptEngines::onErrorMessage);
6645 DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onErrorMessage);6649 connect(scriptEngine.data(), &ScriptEngine::warningMessage, scriptEngines, &ScriptEngines::onWarningMessage);
6646 connect(scriptEngine.data(), &ScriptEngine::warningMessage,6650 connect(scriptEngine.data(), &ScriptEngine::infoMessage, scriptEngines, &ScriptEngines::onInfoMessage);
6647 DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onWarningMessage);6651 connect(scriptEngine.data(), &ScriptEngine::clearDebugWindow, scriptEngines, &ScriptEngines::onClearDebugWindow);
6648 connect(scriptEngine.data(), &ScriptEngine::infoMessage,
6649 DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onInfoMessage);
6650 connect(scriptEngine.data(), &ScriptEngine::clearDebugWindow,
6651 DependencyManager::get<ScriptEngines>().data(), &ScriptEngines::onClearDebugWindow);
6652 6652
6653}6653}
6654 6654
@@ -6956,10 +6956,9 @@ void Application::showDialog(const QUrl& widgetUrl, const QUrl& tabletUrl, const · 301 unmodified lines
6956}6956}
6957 6957
6958void Application::showScriptLogs() {6958void Application::showScriptLogs() {
6959 auto scriptEngines = DependencyManager::get<ScriptEngines>();
6960 QUrl defaultScriptsLoc = PathUtils::defaultScriptsLocation();6959 QUrl defaultScriptsLoc = PathUtils::defaultScriptsLocation();
6961 defaultScriptsLoc.setPath(defaultScriptsLoc.path() + "developer/debugging/debugWindow.js");6960 defaultScriptsLoc.setPath(defaultScriptsLoc.path() + "developer/debugging/debugWindow.js");
6962 scriptEngines->loadScript(defaultScriptsLoc.toString());6961 DependencyManager::get<ScriptEngines>()->loadScript(defaultScriptsLoc.toString());
6963}6962}
6964 6963
6965void Application::showAssetServerWidget(QString filePath) {6964void Application::showAssetServerWidget(QString filePath) {
@@ -7523,7 +7522,6 @@ void Application::openUrl(const QUrl& url) const { · 557 unmodified lines
7523}7522}
7524 7523
7525void Application::loadDialog() {7524void Application::loadDialog() {
7526 auto scriptEngines = DependencyManager::get<ScriptEngines>();
7527 ModalDialogListener* dlg = OffscreenUi::getOpenFileNameAsync(_glWidget, tr("Open Script"),7525 ModalDialogListener* dlg = OffscreenUi::getOpenFileNameAsync(_glWidget, tr("Open Script"),
7528 getPreviousScriptLocation(),7526 getPreviousScriptLocation(),
7529 tr("JavaScript Files (*.js)"));7527 tr("JavaScript Files (*.js)"));