mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 18:23:54 +02:00
Shutdown interface when test script finishes.
This commit is contained in:
parent
46f461dcdb
commit
3a5425122b
3 changed files with 15 additions and 3 deletions
|
@ -2160,7 +2160,9 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
|||
if (testProperty.isValid()) {
|
||||
auto scriptEngines = DependencyManager::get<ScriptEngines>();
|
||||
const auto testScript = property(hifi::properties::TEST).toUrl();
|
||||
scriptEngines->loadScript(testScript, false);
|
||||
|
||||
// Set last parameter to exit interface when the test script finishes
|
||||
scriptEngines->loadScript(testScript, false, false, false, false, true);
|
||||
|
||||
// This is done so we don't get a "connection time-out" message when we haven't passed in a URL.
|
||||
if (arguments().contains("--url")) {
|
||||
|
|
|
@ -456,7 +456,7 @@ void ScriptEngines::reloadAllScripts() {
|
|||
}
|
||||
|
||||
ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool isUserLoaded, bool loadScriptFromEditor,
|
||||
bool activateMainWindow, bool reload) {
|
||||
bool activateMainWindow, bool reload, bool exitWhenFinished) {
|
||||
if (thread() != QThread::currentThread()) {
|
||||
ScriptEnginePointer result { nullptr };
|
||||
BLOCKING_INVOKE_METHOD(this, "loadScript", Q_RETURN_ARG(ScriptEnginePointer, result),
|
||||
|
@ -496,6 +496,11 @@ ScriptEnginePointer ScriptEngines::loadScript(const QUrl& scriptFilename, bool i
|
|||
connect(scriptEngine.data(), &ScriptEngine::scriptLoaded, this, &ScriptEngines::onScriptEngineLoaded);
|
||||
connect(scriptEngine.data(), &ScriptEngine::errorLoadingScript, this, &ScriptEngines::onScriptEngineError);
|
||||
|
||||
// Shutdown interface when script finishes, if requested
|
||||
if (exitWhenFinished) {
|
||||
connect(scriptEngine.data(), &ScriptEngine::finished, this, &ScriptEngines::exitWhenFinished);
|
||||
}
|
||||
|
||||
// get the script engine object to load the script at the designated script URL
|
||||
scriptEngine->loadURL(scriptUrl, reload);
|
||||
}
|
||||
|
@ -536,6 +541,10 @@ void ScriptEngines::onScriptEngineLoaded(const QString& rawScriptURL) {
|
|||
emit scriptCountChanged();
|
||||
}
|
||||
|
||||
void ScriptEngines::exitWhenFinished() {
|
||||
qApp->quit();
|
||||
}
|
||||
|
||||
int ScriptEngines::runScriptInitializers(ScriptEnginePointer scriptEngine) {
|
||||
int ii=0;
|
||||
for (auto initializer : _scriptInitializers) {
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
* @returns {boolean}
|
||||
*/
|
||||
Q_INVOKABLE ScriptEnginePointer loadScript(const QUrl& scriptFilename = QString(),
|
||||
bool isUserLoaded = true, bool loadScriptFromEditor = false, bool activateMainWindow = false, bool reload = false);
|
||||
bool isUserLoaded = true, bool loadScriptFromEditor = false, bool activateMainWindow = false, bool reload = false, bool exitWhenFinished = false);
|
||||
|
||||
/**jsdoc
|
||||
* @function ScriptDiscoveryService.stopScript
|
||||
|
@ -266,6 +266,7 @@ protected:
|
|||
ScriptEnginePointer reloadScript(const QString& scriptName, bool isUserLoaded = true) { return loadScript(scriptName, isUserLoaded, false, false, true); }
|
||||
void removeScriptEngine(ScriptEnginePointer);
|
||||
void onScriptEngineLoaded(const QString& scriptFilename);
|
||||
void exitWhenFinished();
|
||||
void onScriptEngineError(const QString& scriptFilename);
|
||||
void launchScriptEngine(ScriptEnginePointer);
|
||||
|
||||
|
|
Loading…
Reference in a new issue