mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 16:23:39 +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() {
|
||||
_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) {
|
||||
_isFinished = true;
|
||||
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
|
||||
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.
|
||||
void waitTillDoneRunning();
|
||||
|
@ -146,6 +146,8 @@ public:
|
|||
|
||||
bool isFinished() const { return _isFinished; } // used by Application and 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; }
|
||||
void setIsStopping() { _isStopping = true; }
|
||||
|
||||
|
|
|
@ -160,7 +160,6 @@ void ScriptEngines::shutdownScripting() {
|
|||
scriptEngine->disconnect(this);
|
||||
|
||||
// Gracefully stop the engine's scripting thread
|
||||
scriptEngine->setIsStopping();
|
||||
scriptEngine->stop();
|
||||
|
||||
// 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);
|
||||
});
|
||||
}
|
||||
it.value()->setIsStopping();
|
||||
QMetaObject::invokeMethod(it.value(), "stop");
|
||||
it.value()->stop();
|
||||
qCDebug(scriptengine) << "stopping script..." << it.key();
|
||||
}
|
||||
}
|
||||
|
@ -376,7 +374,6 @@ bool ScriptEngines::stopScript(const QString& rawScriptURL, bool restart) {
|
|||
reloadScript(scriptName);
|
||||
});
|
||||
}
|
||||
scriptEngine->setIsStopping();
|
||||
scriptEngine->stop();
|
||||
stoppedScript = true;
|
||||
qCDebug(scriptengine) << "stopping script..." << scriptURL;
|
||||
|
|
Loading…
Reference in a new issue