diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index a797fdf6cf9..10574f330d4 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -7550,12 +7550,18 @@ void Application::registerScriptEngineWithApplicationServices(ScriptManagerPoint } auto scriptingInterface = DependencyManager::get(); scriptEngine->registerGlobalObject("Controller", scriptingInterface.data()); - scriptManager->connect(scriptManager.get(), &ScriptManager::scriptEnding, [scriptManager]() { - // Request removal of controller routes with callbacks to a given script engine - auto userInputMapper = DependencyManager::get(); - userInputMapper->scheduleScriptEndpointCleanup(scriptManager->engine().get()); - // V8TODO: Maybe we should wait until removal is finished if there are still crashes - }); + + { + auto connection = std::make_shared(); + *connection = scriptManager->connect(scriptManager.get(), &ScriptManager::scriptEnding, [scriptManager, connection]() { + // Request removal of controller routes with callbacks to a given script engine + auto userInputMapper = DependencyManager::get(); + userInputMapper->scheduleScriptEndpointCleanup(scriptManager->engine().get()); + // V8TODO: Maybe we should wait until endpoint cleanup is finished before deleting the script engine if there are still crashes + QObject::disconnect(*connection); + }); + } + UserInputMapper::registerControllerTypes(scriptEngine.get()); auto recordingInterface = DependencyManager::get(); diff --git a/libraries/script-engine/src/ScriptManagerScriptingInterface.cpp b/libraries/script-engine/src/ScriptManagerScriptingInterface.cpp index 144b0e413a6..1c0edc48897 100644 --- a/libraries/script-engine/src/ScriptManagerScriptingInterface.cpp +++ b/libraries/script-engine/src/ScriptManagerScriptingInterface.cpp @@ -32,7 +32,6 @@ connect(_manager, &ScriptManager::errorLoadingScript, this, &ScriptManagerScriptingInterface::errorLoadingScript); connect(_manager, &ScriptManager::update, this, &ScriptManagerScriptingInterface::update); connect(_manager, &ScriptManager::scriptEnding, this, &ScriptManagerScriptingInterface::scriptEnding); - connect(_manager, &ScriptManager::finished, this, &ScriptManagerScriptingInterface::finished); connect(_manager, &ScriptManager::printedMessage, this, &ScriptManagerScriptingInterface::printedMessage); connect(_manager, &ScriptManager::errorMessage, this, &ScriptManagerScriptingInterface::errorMessage); connect(_manager, &ScriptManager::warningMessage, this, &ScriptManagerScriptingInterface::warningMessage); diff --git a/libraries/script-engine/src/ScriptManagerScriptingInterface.h b/libraries/script-engine/src/ScriptManagerScriptingInterface.h index 5620a9fb138..68d9dba794c 100644 --- a/libraries/script-engine/src/ScriptManagerScriptingInterface.h +++ b/libraries/script-engine/src/ScriptManagerScriptingInterface.h @@ -577,15 +577,6 @@ class ScriptManagerScriptingInterface : public QObject { */ void scriptEnding(); - /*@jsdoc - * @function Script.finished - * @param {string} filename - File name. - * @param {object} engine - Engine. - * @returns {Signal} - * @deprecated This signal is deprecated and will be removed. - */ - void finished(const QString& fileNameString, ScriptManagerPointer); - /*@jsdoc * Triggered when the script prints a message to the program log via {@link print}, {@link Script.print}, * {@link console.log}, {@link console.debug}, {@link console.group}, {@link console.groupEnd}, {@link console.time}, or