mirror of
https://github.com/overte-org/overte.git
synced 2025-07-10 14:38:31 +02:00
code review
This commit is contained in:
parent
3f5ed4bef8
commit
aa58cad93e
3 changed files with 11 additions and 5 deletions
|
@ -938,6 +938,13 @@ void ScriptEngine::stopAllTimersForEntityScript(const EntityItemID& entityID) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEngine::stop() {
|
void ScriptEngine::stop() {
|
||||||
|
_isStopping = true; // this can be done on any thread
|
||||||
|
|
||||||
|
// marshal us over to the correct thread
|
||||||
|
if (QThread::currentThread() != thread()) {
|
||||||
|
QMetaObject::invokeMethod(this, "stop");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!_isFinished) {
|
if (!_isFinished) {
|
||||||
_isFinished = true;
|
_isFinished = true;
|
||||||
emit runningStateChanged();
|
emit runningStateChanged();
|
||||||
|
|
|
@ -84,7 +84,7 @@ public:
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// NOTE - this is intended to be a public interface for Agent scripts, and local scripts, but not for EntityScripts
|
// NOTE - this is intended to be a public interface for Agent scripts, and local scripts, but not for EntityScripts
|
||||||
Q_INVOKABLE void stop();
|
Q_INVOKABLE void stop(); // this can be called from any thread
|
||||||
|
|
||||||
// Stop any evaluating scripts and wait for the scripting thread to finish.
|
// Stop any evaluating scripts and wait for the scripting thread to finish.
|
||||||
void waitTillDoneRunning();
|
void waitTillDoneRunning();
|
||||||
|
@ -146,6 +146,8 @@ public:
|
||||||
|
|
||||||
bool isFinished() const { return _isFinished; } // used by Application and ScriptWidget
|
bool isFinished() const { return _isFinished; } // used by Application and ScriptWidget
|
||||||
bool isRunning() const { return _isRunning; } // used by ScriptWidget
|
bool isRunning() const { return _isRunning; } // used by ScriptWidget
|
||||||
|
|
||||||
|
// these are used by code in ScriptEngines.cpp during the "reload all" operation
|
||||||
bool isStopping() const { return _isStopping; }
|
bool isStopping() const { return _isStopping; }
|
||||||
void setIsStopping() { _isStopping = true; }
|
void setIsStopping() { _isStopping = true; }
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,6 @@ void ScriptEngines::shutdownScripting() {
|
||||||
scriptEngine->disconnect(this);
|
scriptEngine->disconnect(this);
|
||||||
|
|
||||||
// Gracefully stop the engine's scripting thread
|
// Gracefully stop the engine's scripting thread
|
||||||
scriptEngine->setIsStopping();
|
|
||||||
scriptEngine->stop();
|
scriptEngine->stop();
|
||||||
|
|
||||||
// We need to wait for the engine to be done running before we proceed, because we don't
|
// We need to wait for the engine to be done running before we proceed, because we don't
|
||||||
|
@ -352,8 +351,7 @@ void ScriptEngines::stopAllScripts(bool restart) {
|
||||||
reloadScript(scriptName);
|
reloadScript(scriptName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
it.value()->setIsStopping();
|
it.value()->stop();
|
||||||
QMetaObject::invokeMethod(it.value(), "stop");
|
|
||||||
qCDebug(scriptengine) << "stopping script..." << it.key();
|
qCDebug(scriptengine) << "stopping script..." << it.key();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -376,7 +374,6 @@ bool ScriptEngines::stopScript(const QString& rawScriptURL, bool restart) {
|
||||||
reloadScript(scriptName);
|
reloadScript(scriptName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
scriptEngine->setIsStopping();
|
|
||||||
scriptEngine->stop();
|
scriptEngine->stop();
|
||||||
stoppedScript = true;
|
stoppedScript = true;
|
||||||
qCDebug(scriptengine) << "stopping script..." << scriptURL;
|
qCDebug(scriptengine) << "stopping script..." << scriptURL;
|
||||||
|
|
Loading…
Reference in a new issue