Fixed interface scripts failing to shutdown and removed deprecated API signal

This commit is contained in:
ksuprynowicz 2023-07-20 00:15:00 +02:00
parent 72137f52f7
commit 790a55d093
3 changed files with 12 additions and 16 deletions

View file

@ -7550,12 +7550,18 @@ void Application::registerScriptEngineWithApplicationServices(ScriptManagerPoint
}
auto scriptingInterface = DependencyManager::get<controller::ScriptingInterface>();
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>();
userInputMapper->scheduleScriptEndpointCleanup(scriptManager->engine().get());
// V8TODO: Maybe we should wait until removal is finished if there are still crashes
});
{
auto connection = std::make_shared<QMetaObject::Connection>();
*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>();
userInputMapper->scheduleScriptEndpointCleanup(scriptManager->engine().get());
QObject::disconnect(*connection);
// V8TODO: Maybe we should wait until removal is finished if there are still crashes
});
}
UserInputMapper::registerControllerTypes(scriptEngine.get());
auto recordingInterface = DependencyManager::get<RecordingScriptingInterface>();

View file

@ -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);

View file

@ -577,15 +577,6 @@ signals:
*/
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