diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 062a8fa9c1..1803b5e19f 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -2761,7 +2761,6 @@ void Application::cleanupBeforeQuit() { } getEntities()->shutdown(); // tell the entities system we're shutting down, so it will stop running scripts - getEntities()->clear(); // Clear any queued processing (I/O, FBX/OBJ/Texture parsing) QThreadPool::globalInstance()->clear(); diff --git a/libraries/entities-renderer/src/EntityTreeRenderer.cpp b/libraries/entities-renderer/src/EntityTreeRenderer.cpp index 305384361d..fd82567a94 100644 --- a/libraries/entities-renderer/src/EntityTreeRenderer.cpp +++ b/libraries/entities-renderer/src/EntityTreeRenderer.cpp @@ -253,7 +253,7 @@ void EntityTreeRenderer::clear() { // unload and stop the engine if (_entitiesScriptEngine) { // do this here (instead of in deleter) to avoid marshalling unload signals back to this thread - _entitiesScriptEngine->unloadAllEntityScripts(); + _entitiesScriptEngine->unloadAllEntityScripts(true); _entitiesScriptEngine->stop(); } diff --git a/libraries/script-engine/src/ScriptEngine.cpp b/libraries/script-engine/src/ScriptEngine.cpp index 5e20f06a7f..6808da2e1a 100644 --- a/libraries/script-engine/src/ScriptEngine.cpp +++ b/libraries/script-engine/src/ScriptEngine.cpp @@ -2470,13 +2470,14 @@ QList ScriptEngine::getListOfEntityScriptIDs() { return _entityScripts.keys(); } -void ScriptEngine::unloadAllEntityScripts() { +void ScriptEngine::unloadAllEntityScripts(bool blockingCall) { if (QThread::currentThread() != thread()) { #ifdef THREAD_DEBUGGING qCDebug(scriptengine) << "*** WARNING *** ScriptEngine::unloadAllEntityScripts() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "]"; #endif - QMetaObject::invokeMethod(this, "unloadAllEntityScripts"); + QMetaObject::invokeMethod(this, "unloadAllEntityScripts", + blockingCall ? Qt::BlockingQueuedConnection : Qt::QueuedConnection); return; } #ifdef THREAD_DEBUGGING diff --git a/libraries/script-engine/src/ScriptEngine.h b/libraries/script-engine/src/ScriptEngine.h index 52ece63dc2..d738b13ecc 100644 --- a/libraries/script-engine/src/ScriptEngine.h +++ b/libraries/script-engine/src/ScriptEngine.h @@ -578,9 +578,10 @@ public: /**jsdoc * @function Script.unloadAllEntityScripts + * @param {boolean} [blockingCall=false] - Wait for completion if call moved to another thread. * @deprecated This function is deprecated and will be removed. */ - Q_INVOKABLE void unloadAllEntityScripts(); + Q_INVOKABLE void unloadAllEntityScripts(bool blockingCall = false); /**jsdoc * Calls a method in an entity script. diff --git a/scripts/modules/request.js b/scripts/modules/request.js index 48c9913bd6..7e942a47f7 100644 --- a/scripts/modules/request.js +++ b/scripts/modules/request.js @@ -40,10 +40,10 @@ module.exports = { response = { statusCode: httpRequest.status }; } + callback(error, response, optionalCallbackParameter); + // Break circular reference to httpRequest so the engine can garbage collect it. httpRequest.onreadystatechange = null; - - callback(error, response, optionalCallbackParameter); } }; if (typeof options === 'string') { diff --git a/scripts/simplifiedUI/ui/simplifiedUI.js b/scripts/simplifiedUI/ui/simplifiedUI.js index 46e10847f9..fb7f2824d6 100644 --- a/scripts/simplifiedUI/ui/simplifiedUI.js +++ b/scripts/simplifiedUI/ui/simplifiedUI.js @@ -483,7 +483,16 @@ function updateInputDeviceMutedOverlay(isMuted) { function onDesktopInputDeviceMutedChanged(isMuted) { - updateInputDeviceMutedOverlay(isMuted); + if (!HMD.active) { + updateInputDeviceMutedOverlay(isMuted); + } +} + + +function onHMDInputDeviceMutedChanged(isMuted) { + if (HMD.active) { + updateInputDeviceMutedOverlay(isMuted); + } } @@ -508,6 +517,12 @@ function onDisplayModeChanged(isHMDMode) { if (isHMDMode) { Camera.setModeString("first person"); } + + if (isHMDMode) { + onHMDInputDeviceMutedChanged(Audio.mutedHMD); + } else { + onDesktopInputDeviceMutedChanged(Audio.mutedDesktop); + } } function onToolbarVisibleChanged(isVisible, toolbarName) { @@ -578,6 +593,7 @@ function startup() { updateInputDeviceMutedOverlay(Audio.muted); updateOutputDeviceMutedOverlay(isOutputMuted()); Audio.mutedDesktopChanged.connect(onDesktopInputDeviceMutedChanged); + Audio.mutedHMDChanged.connect(onHMDInputDeviceMutedChanged); Window.geometryChanged.connect(onGeometryChanged); HMD.displayModeChanged.connect(onDisplayModeChanged); Audio.avatarGainChanged.connect(maybeUpdateOutputDeviceMutedOverlay); @@ -634,6 +650,7 @@ function shutdown() { si.unload(); Audio.mutedDesktopChanged.disconnect(onDesktopInputDeviceMutedChanged); + Audio.mutedHMDChanged.disconnect(onHMDInputDeviceMutedChanged); Window.geometryChanged.disconnect(onGeometryChanged); HMD.displayModeChanged.disconnect(onDisplayModeChanged); Audio.avatarGainChanged.disconnect(maybeUpdateOutputDeviceMutedOverlay);