mirror of
https://github.com/overte-org/overte.git
synced 2025-07-10 08:38:43 +02:00
Rename ScriptEngine::wait to match std threading
This commit is contained in:
parent
edf82c57ba
commit
2cc788f98d
3 changed files with 8 additions and 5 deletions
|
@ -284,8 +284,7 @@ void ScriptEngine::runInThread() {
|
|||
workerThread->start();
|
||||
}
|
||||
|
||||
void ScriptEngine::waitTillDoneRunning() {
|
||||
// If the script never started running or finished running before we got here, we don't need to wait for it
|
||||
void ScriptEngine::wait() {
|
||||
auto workerThread = thread();
|
||||
|
||||
if (_isThreaded && workerThread) {
|
||||
|
|
|
@ -197,7 +197,10 @@ protected:
|
|||
|
||||
void init();
|
||||
QString getFilename() const;
|
||||
void waitTillDoneRunning();
|
||||
|
||||
// Stop any evaluating scripts and wait for the scripting thread to finish.
|
||||
void wait();
|
||||
|
||||
bool evaluatePending() const { return _evaluatesPending > 0; }
|
||||
void timerFired();
|
||||
void stopAllTimers();
|
||||
|
|
|
@ -149,6 +149,7 @@ void ScriptEngines::shutdownScripting() {
|
|||
// NOTE: typically all script engines are running. But there's at least one known exception to this, the
|
||||
// "entities sandbox" which is only used to evaluate entities scripts to test their validity before using
|
||||
// them. We don't need to stop scripts that aren't running.
|
||||
// TODO: Scripts could be shut down faster if we spread them across a threadpool.
|
||||
if (scriptEngine->isRunning()) {
|
||||
qCDebug(scriptengine) << "about to shutdown script:" << scriptName;
|
||||
|
||||
|
@ -165,12 +166,12 @@ void ScriptEngines::shutdownScripting() {
|
|||
// want any of the scripts final "scriptEnding()" or pending "update()" methods from accessing
|
||||
// any application state after we leave this stopAllScripts() method
|
||||
qCDebug(scriptengine) << "waiting on script:" << scriptName;
|
||||
scriptEngine->waitTillDoneRunning();
|
||||
scriptEngine->wait();
|
||||
qCDebug(scriptengine) << "done waiting on script:" << scriptName;
|
||||
|
||||
scriptEngine->deleteLater();
|
||||
|
||||
// If the script is stopped, we can remove it from our set
|
||||
// Once the script is stopped, we can remove it from our set
|
||||
i.remove();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue