mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-14 11:46:34 +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
|
||||
|
||||
if (_scriptEngine) {
|
||||
_scriptEngine->stop(false);
|
||||
_scriptEngine->stop();
|
||||
}
|
||||
|
||||
// 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
|
||||
// avoid marshalling unload signals back to this thread
|
||||
_entitiesScriptEngine->unloadAllEntityScripts();
|
||||
_entitiesScriptEngine->stop(false);
|
||||
_entitiesScriptEngine->stop();
|
||||
}
|
||||
|
||||
if (_wantScripts && !_shuttingDown) {
|
||||
|
|
|
@ -290,7 +290,7 @@ void ScriptEngine::waitTillDoneRunning() {
|
|||
assert(workerThread != QThread::currentThread());
|
||||
|
||||
// Engine should be stopped already, but be defensive
|
||||
stop(false);
|
||||
stop();
|
||||
|
||||
auto startedWaiting = usecTimestampNow();
|
||||
while (workerThread->isRunning()) {
|
||||
|
@ -944,12 +944,9 @@ void ScriptEngine::stopAllTimersForEntityScript(const EntityItemID& entityID) {
|
|||
void ScriptEngine::stop(bool marshal) {
|
||||
_isStopping = true; // this can be done on any thread
|
||||
|
||||
// marshal us over to the correct thread
|
||||
if (marshal) {
|
||||
if (QThread::currentThread() != thread()) {
|
||||
QMetaObject::invokeMethod(this, "stop");
|
||||
return;
|
||||
}
|
||||
QMetaObject::invokeMethod(this, "stop");
|
||||
return;
|
||||
}
|
||||
if (!_isFinished) {
|
||||
_isFinished = true;
|
||||
|
|
|
@ -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(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.
|
||||
void waitTillDoneRunning();
|
||||
|
|
|
@ -160,7 +160,7 @@ void ScriptEngines::shutdownScripting() {
|
|||
scriptEngine->disconnect(this);
|
||||
|
||||
// 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
|
||||
// want any of the scripts final "scriptEnding()" or pending "update()" methods from accessing
|
||||
|
@ -359,10 +359,7 @@ QStringList ScriptEngines::getRunningScripts() {
|
|||
QList<QUrl> urls = _scriptEnginesHash.keys();
|
||||
QStringList result;
|
||||
for (auto url : urls) {
|
||||
ScriptEngine* engine = getScriptEngineInternal(url);
|
||||
if (engine) {
|
||||
result.append(url.toString());
|
||||
}
|
||||
result.append(url.toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -383,7 +380,7 @@ void ScriptEngines::stopAllScripts(bool restart) {
|
|||
// Stop and possibly restart all currently running scripts
|
||||
for (QHash<QUrl, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();
|
||||
it != _scriptEnginesHash.constEnd(); it++) {
|
||||
if (it.value()->isFinished()) {
|
||||
if (it.value()->isFinished() || it.value()->isStopping()) {
|
||||
continue;
|
||||
}
|
||||
if (restart && it.value()->isUserLoaded()) {
|
||||
|
@ -414,7 +411,7 @@ bool ScriptEngines::stopScript(const QString& rawScriptURL, bool restart) {
|
|||
reloadScript(scriptName);
|
||||
});
|
||||
}
|
||||
scriptEngine->stop(false);
|
||||
scriptEngine->stop();
|
||||
stoppedScript = true;
|
||||
qCDebug(scriptengine) << "stopping script..." << scriptURL;
|
||||
}
|
||||
|
@ -487,21 +484,19 @@ ScriptEngine* ScriptEngines::loadScript(const QUrl& scriptFilename, bool isUserL
|
|||
return scriptEngine;
|
||||
}
|
||||
|
||||
ScriptEngine* ScriptEngines::getScriptEngineInternal(const QUrl& rawScriptURL) {
|
||||
ScriptEngine* ScriptEngines::getScriptEngine(const QUrl& rawScriptURL) {
|
||||
ScriptEngine* result = nullptr;
|
||||
const QUrl scriptURL = normalizeScriptURL(rawScriptURL);
|
||||
auto it = _scriptEnginesHash.find(scriptURL);
|
||||
if (it != _scriptEnginesHash.end()) {
|
||||
result = it.value();
|
||||
{
|
||||
QReadLocker lock(&_scriptEnginesHashLock);
|
||||
const QUrl scriptURL = normalizeScriptURL(rawScriptURL);
|
||||
auto it = _scriptEnginesHash.find(scriptURL);
|
||||
if (it != _scriptEnginesHash.end()) {
|
||||
result = it.value();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ScriptEngine* ScriptEngines::getScriptEngine(const QUrl& rawScriptURL) {
|
||||
QReadLocker lock(&_scriptEnginesHashLock);
|
||||
return getScriptEngineInternal(rawScriptURL);
|
||||
}
|
||||
|
||||
// FIXME - change to new version of ScriptCache loading notification
|
||||
void ScriptEngines::onScriptEngineLoaded(const QString& rawScriptURL) {
|
||||
UserActivityLogger::getInstance().loadedScript(rawScriptURL);
|
||||
|
|
|
@ -87,7 +87,6 @@ protected:
|
|||
void onScriptEngineLoaded(const QString& scriptFilename);
|
||||
void onScriptEngineError(const QString& scriptFilename);
|
||||
void launchScriptEngine(ScriptEngine* engine);
|
||||
ScriptEngine* getScriptEngineInternal(const QUrl& rawScriptURL);
|
||||
|
||||
QReadWriteLock _scriptEnginesHashLock;
|
||||
QHash<QUrl, ScriptEngine*> _scriptEnginesHash;
|
||||
|
|
Loading…
Reference in a new issue