mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:37:51 +02:00
trying again -- frantic clicking on reload no longer appears to wedge things
This commit is contained in:
parent
75329c812c
commit
49769f7d29
6 changed files with 18 additions and 27 deletions
|
@ -476,7 +476,7 @@ void Agent::aboutToFinish() {
|
||||||
setIsAvatar(false);// will stop timers for sending identity packets
|
setIsAvatar(false);// will stop timers for sending identity packets
|
||||||
|
|
||||||
if (_scriptEngine) {
|
if (_scriptEngine) {
|
||||||
_scriptEngine->stop(false);
|
_scriptEngine->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// our entity tree is going to go away so tell that to the EntityScriptingInterface
|
// our entity tree is going to go away so tell that to the EntityScriptingInterface
|
||||||
|
|
|
@ -114,7 +114,7 @@ void EntityTreeRenderer::clear() {
|
||||||
// Unload and stop the engine here (instead of in its deleter) to
|
// Unload and stop the engine here (instead of in its deleter) to
|
||||||
// avoid marshalling unload signals back to this thread
|
// avoid marshalling unload signals back to this thread
|
||||||
_entitiesScriptEngine->unloadAllEntityScripts();
|
_entitiesScriptEngine->unloadAllEntityScripts();
|
||||||
_entitiesScriptEngine->stop(false);
|
_entitiesScriptEngine->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_wantScripts && !_shuttingDown) {
|
if (_wantScripts && !_shuttingDown) {
|
||||||
|
|
|
@ -290,7 +290,7 @@ void ScriptEngine::waitTillDoneRunning() {
|
||||||
assert(workerThread != QThread::currentThread());
|
assert(workerThread != QThread::currentThread());
|
||||||
|
|
||||||
// Engine should be stopped already, but be defensive
|
// Engine should be stopped already, but be defensive
|
||||||
stop(false);
|
stop();
|
||||||
|
|
||||||
auto startedWaiting = usecTimestampNow();
|
auto startedWaiting = usecTimestampNow();
|
||||||
while (workerThread->isRunning()) {
|
while (workerThread->isRunning()) {
|
||||||
|
@ -944,13 +944,10 @@ void ScriptEngine::stopAllTimersForEntityScript(const EntityItemID& entityID) {
|
||||||
void ScriptEngine::stop(bool marshal) {
|
void ScriptEngine::stop(bool marshal) {
|
||||||
_isStopping = true; // this can be done on any thread
|
_isStopping = true; // this can be done on any thread
|
||||||
|
|
||||||
// marshal us over to the correct thread
|
|
||||||
if (marshal) {
|
if (marshal) {
|
||||||
if (QThread::currentThread() != thread()) {
|
|
||||||
QMetaObject::invokeMethod(this, "stop");
|
QMetaObject::invokeMethod(this, "stop");
|
||||||
return;
|
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(bool marshal); // this can be called from any thread
|
Q_INVOKABLE void stop(bool marshal = false);
|
||||||
|
|
||||||
// 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();
|
||||||
|
|
|
@ -160,7 +160,7 @@ void ScriptEngines::shutdownScripting() {
|
||||||
scriptEngine->disconnect(this);
|
scriptEngine->disconnect(this);
|
||||||
|
|
||||||
// Gracefully stop the engine's scripting thread
|
// Gracefully stop the engine's scripting thread
|
||||||
scriptEngine->stop(false);
|
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
|
||||||
// want any of the scripts final "scriptEnding()" or pending "update()" methods from accessing
|
// want any of the scripts final "scriptEnding()" or pending "update()" methods from accessing
|
||||||
|
@ -359,11 +359,8 @@ QStringList ScriptEngines::getRunningScripts() {
|
||||||
QList<QUrl> urls = _scriptEnginesHash.keys();
|
QList<QUrl> urls = _scriptEnginesHash.keys();
|
||||||
QStringList result;
|
QStringList result;
|
||||||
for (auto url : urls) {
|
for (auto url : urls) {
|
||||||
ScriptEngine* engine = getScriptEngineInternal(url);
|
|
||||||
if (engine) {
|
|
||||||
result.append(url.toString());
|
result.append(url.toString());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -383,7 +380,7 @@ void ScriptEngines::stopAllScripts(bool restart) {
|
||||||
// Stop and possibly restart all currently running scripts
|
// Stop and possibly restart all currently running scripts
|
||||||
for (QHash<QUrl, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();
|
for (QHash<QUrl, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();
|
||||||
it != _scriptEnginesHash.constEnd(); it++) {
|
it != _scriptEnginesHash.constEnd(); it++) {
|
||||||
if (it.value()->isFinished()) {
|
if (it.value()->isFinished() || it.value()->isStopping()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (restart && it.value()->isUserLoaded()) {
|
if (restart && it.value()->isUserLoaded()) {
|
||||||
|
@ -414,7 +411,7 @@ bool ScriptEngines::stopScript(const QString& rawScriptURL, bool restart) {
|
||||||
reloadScript(scriptName);
|
reloadScript(scriptName);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
scriptEngine->stop(false);
|
scriptEngine->stop();
|
||||||
stoppedScript = true;
|
stoppedScript = true;
|
||||||
qCDebug(scriptengine) << "stopping script..." << scriptURL;
|
qCDebug(scriptengine) << "stopping script..." << scriptURL;
|
||||||
}
|
}
|
||||||
|
@ -487,19 +484,17 @@ ScriptEngine* ScriptEngines::loadScript(const QUrl& scriptFilename, bool isUserL
|
||||||
return scriptEngine;
|
return scriptEngine;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptEngine* ScriptEngines::getScriptEngineInternal(const QUrl& rawScriptURL) {
|
ScriptEngine* ScriptEngines::getScriptEngine(const QUrl& rawScriptURL) {
|
||||||
ScriptEngine* result = nullptr;
|
ScriptEngine* result = nullptr;
|
||||||
|
{
|
||||||
|
QReadLocker lock(&_scriptEnginesHashLock);
|
||||||
const QUrl scriptURL = normalizeScriptURL(rawScriptURL);
|
const QUrl scriptURL = normalizeScriptURL(rawScriptURL);
|
||||||
auto it = _scriptEnginesHash.find(scriptURL);
|
auto it = _scriptEnginesHash.find(scriptURL);
|
||||||
if (it != _scriptEnginesHash.end()) {
|
if (it != _scriptEnginesHash.end()) {
|
||||||
result = it.value();
|
result = it.value();
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
ScriptEngine* ScriptEngines::getScriptEngine(const QUrl& rawScriptURL) {
|
|
||||||
QReadLocker lock(&_scriptEnginesHashLock);
|
|
||||||
return getScriptEngineInternal(rawScriptURL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME - change to new version of ScriptCache loading notification
|
// FIXME - change to new version of ScriptCache loading notification
|
||||||
|
|
|
@ -87,7 +87,6 @@ protected:
|
||||||
void onScriptEngineLoaded(const QString& scriptFilename);
|
void onScriptEngineLoaded(const QString& scriptFilename);
|
||||||
void onScriptEngineError(const QString& scriptFilename);
|
void onScriptEngineError(const QString& scriptFilename);
|
||||||
void launchScriptEngine(ScriptEngine* engine);
|
void launchScriptEngine(ScriptEngine* engine);
|
||||||
ScriptEngine* getScriptEngineInternal(const QUrl& rawScriptURL);
|
|
||||||
|
|
||||||
QReadWriteLock _scriptEnginesHashLock;
|
QReadWriteLock _scriptEnginesHashLock;
|
||||||
QHash<QUrl, ScriptEngine*> _scriptEnginesHash;
|
QHash<QUrl, ScriptEngine*> _scriptEnginesHash;
|
||||||
|
|
Loading…
Reference in a new issue