Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all
Unified · Split
| @@ -1077,13 +1077,21 @@ void ScriptEngine::loadEntityScript(const EntityItemID& entityID, const QString& · 1076 unmodified lines | |||
| 1077 | qDebug() << "ScriptEngine::loadEntityScript() calling scriptCache->getScriptContents() on thread [" | 1077 | qDebug() << "ScriptEngine::loadEntityScript() calling scriptCache->getScriptContents() on thread [" |
| 1078 | << QThread::currentThread() << "] expected thread [" << thread() << "]"; | 1078 | << QThread::currentThread() << "] expected thread [" << thread() << "]"; |
| 1079 | #endif | 1079 | #endif |
| 1080 | DependencyManager::get<ScriptCache>()->getScriptContents(entityScript, [=](const QString& scriptOrURL, const QString& contents, bool isURL, bool success) { | 1080 | |
| 1081 | QPointer<ScriptEngine> theEngine(this); | ||
| 1082 | |||
| 1083 | DependencyManager::get<ScriptCache>()->getScriptContents(entityScript, [theEngine, entityID](const QString& scriptOrURL, const QString& contents, bool isURL, bool success) { | ||
| 1081 | #ifdef THREAD_DEBUGGING | 1084 | #ifdef THREAD_DEBUGGING |
| 1082 | qDebug() << "ScriptEngine::entityScriptContentAvailable() IN LAMBDA contentAvailable on thread [" | 1085 | qDebug() << "ScriptEngine::entityScriptContentAvailable() IN LAMBDA contentAvailable on thread [" |
| 1083 | << QThread::currentThread() << "] expected thread [" << thread() << "]"; | 1086 | << QThread::currentThread() << "] expected thread [" << thread() << "]"; |
| 1084 | #endif | 1087 | #endif |
| 1085 | 1088 | ||
| 1086 | this->entityScriptContentAvailable(entityID, scriptOrURL, contents, isURL, success); | 1089 | if (!theEngine.isNull()) { |
| 1090 | qDebug() << "ScriptCache::getScriptContents() returned ScriptEngine still active calling ... entityScriptContentAvailable()"; | ||
| 1091 | theEngine->entityScriptContentAvailable(entityID, scriptOrURL, contents, isURL, success); | ||
| 1092 | } else { | ||
| 1093 | qDebug() << "ScriptCache::getScriptContents() returned after our ScriptEngine was deleted..."; | ||
| 1094 | } | ||
| 1087 | }, forceRedownload); | 1095 | }, forceRedownload); |
| 1088 | } | 1096 | } |
| 1089 | 1097 | ||