Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 6 files). Show all
Unified · Split
| @@ -999,6 +999,24 @@ void ScriptEngine::unloadEntityScript(const EntityItemID& entityID) { · 998 unmodified lines | |||
| 999 | } | 999 | } |
| 1000 | } | 1000 | } |
| 1001 | 1001 | ||
| 1002 | void ScriptEngine::unloadAllEntityScripts() { | ||
| 1003 | if (QThread::currentThread() != thread()) { | ||
| 1004 | #ifdef THREAD_DEBUGGING | ||
| 1005 | qDebug() << "*** WARNING *** ScriptEngine::unloadAllEntityScripts() called on wrong thread [" << QThread::currentThread() << "], invoking on correct thread [" << thread() << "]"; | ||
| 1006 | #endif | ||
| 1007 | |||
| 1008 | QMetaObject::invokeMethod(this, "unloadAllEntityScripts"); | ||
| 1009 | return; | ||
| 1010 | } | ||
| 1011 | #ifdef THREAD_DEBUGGING | ||
| 1012 | qDebug() << "ScriptEngine::unloadAllEntityScripts() called on correct thread [" << thread() << "]"; | ||
| 1013 | #endif | ||
| 1014 | foreach(const EntityItemID& entityID, _entityScripts.keys()) { | ||
| 1015 | callEntityScriptMethod(entityID, "unload"); | ||
| 1016 | } | ||
| 1017 | _entityScripts.clear(); | ||
| 1018 | } | ||
| 1019 | |||
| 1002 | void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName) { | 1020 | void ScriptEngine::callEntityScriptMethod(const EntityItemID& entityID, const QString& methodName) { |
| 1003 | if (QThread::currentThread() != thread()) { | 1021 | if (QThread::currentThread() != thread()) { |
| 1004 | #ifdef THREAD_DEBUGGING | 1022 | #ifdef THREAD_DEBUGGING |