History

cleanup

Brad Hefta-Gaub committed 10 years ago

Commit d1f6b371 parent a4f56263 files · +4 −73Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 3 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+4−38
@@ -142,10 +142,7 @@ ScriptEngine::ScriptEngine(const QString& scriptContents, const QString& fileNam · 141 unmodified lines
142}142}
143 143
144ScriptEngine::~ScriptEngine() {144ScriptEngine::~ScriptEngine() {
145 qCDebug(scriptengine) << __FUNCTION__ << "--- BEGIN --- script:" << getFilename();
146 qCDebug(scriptengine) << __FUNCTION__ << "called on thread[" << QThread::currentThread() << "], object's thread [" << thread() << "] script:" << getFilename();
147 qCDebug(scriptengine) << "Script Engine shutting down (destructor) for script:" << getFilename();145 qCDebug(scriptengine) << "Script Engine shutting down (destructor) for script:" << getFilename();
148
149 auto scriptEngines = DependencyManager::get<ScriptEngines>();146 auto scriptEngines = DependencyManager::get<ScriptEngines>();
150 if (scriptEngines) {147 if (scriptEngines) {
151 qCDebug(scriptengine) << "About to remove ScriptEngine [" << getFilename() << "] from ScriptEngines!";148 qCDebug(scriptengine) << "About to remove ScriptEngine [" << getFilename() << "] from ScriptEngines!";
@@ -154,7 +151,6 @@ ScriptEngine::~ScriptEngine() { · 2 unmodified lines
154 } else {151 } else {
155 qCWarning(scriptengine) << "Script destroyed after ScriptEngines!";152 qCWarning(scriptengine) << "Script destroyed after ScriptEngines!";
156 }153 }
157 qCDebug(scriptengine) << __FUNCTION__ << "--- END --- script:" << getFilename();
158}154}
159 155
160void ScriptEngine::disconnectNonEssentialSignals() {156void ScriptEngine::disconnectNonEssentialSignals() {
@@ -1053,36 +1049,6 @@ void ScriptEngine::forwardHandlerCall(const EntityItemID& entityID, const QStrin · 892 unmodified lines
1053// since all of these operations can be asynch we will always do the actual work in the response handler1049// since all of these operations can be asynch we will always do the actual work in the response handler
1054// for the download1050// for the download
1055void ScriptEngine::loadEntityScript(QWeakPointer<ScriptEngine> theEngine, const EntityItemID& entityID, const QString& entityScript, bool forceRedownload) {1051void ScriptEngine::loadEntityScript(QWeakPointer<ScriptEngine> theEngine, const EntityItemID& entityID, const QString& entityScript, bool forceRedownload) {
1056
1057
1058/*****
1059 if (QThread::currentThread() != thread()) {
1060#ifdef THREAD_DEBUGGING
1061 qDebug() << "*** WARNING *** ScriptEngine::loadEntityScript() called on wrong thread ["
1062 << QThread::currentThread() << "], invoking on correct thread [" << thread() << "] "
1063 "entityID:" << entityID << "entityScript:" << entityScript <<"forceRedownload:" << forceRedownload;
1064#endif
1065
1066 QMetaObject::invokeMethod(this, "loadEntityScript",
1067 Q_ARG(const EntityItemID&, entityID),
1068 Q_ARG(const QString&, entityScript),
1069 Q_ARG(bool, forceRedownload));
1070 return;
1071 }
1072#ifdef THREAD_DEBUGGING
1073 qDebug() << "ScriptEngine::loadEntityScript() called on correct thread [" << thread() << "] "
1074 "entityID:" << entityID << "entityScript:" << entityScript << "forceRedownload:" << forceRedownload;
1075#endif
1076
1077 // If we've been called our known entityScripts should not know about us..
1078 assert(!_entityScripts.contains(entityID));
1079
1080#ifdef THREAD_DEBUGGING
1081 qDebug() << "ScriptEngine::loadEntityScript() calling scriptCache->getScriptContents() on thread ["
1082 << QThread::currentThread() << "] expected thread [" << thread() << "]";
1083#endif
1084******/
1085
1086 // NOTE: If the script content is not currently in the caceh, The LAMBDA here, will be called on the Main Thread1052 // NOTE: If the script content is not currently in the caceh, The LAMBDA here, will be called on the Main Thread
1087 // which means we're guarenteed that it's not the correct thread for the ScriptEngine. This means1053 // which means we're guarenteed that it's not the correct thread for the ScriptEngine. This means
1088 // when we get into entityScriptContentAvailable() we will likely invokeMethod() to get it over1054 // when we get into entityScriptContentAvailable() we will likely invokeMethod() to get it over
@@ -1090,15 +1056,15 @@ void ScriptEngine::loadEntityScript(QWeakPointer<ScriptEngine> theEngine, const · 1 unmodified line
1090 DependencyManager::get<ScriptCache>()->getScriptContents(entityScript, [theEngine, entityID](const QString& scriptOrURL, const QString& contents, bool isURL, bool success) {1056 DependencyManager::get<ScriptCache>()->getScriptContents(entityScript, [theEngine, entityID](const QString& scriptOrURL, const QString& contents, bool isURL, bool success) {
1091 QSharedPointer<ScriptEngine> strongEngine = theEngine.toStrongRef();1057 QSharedPointer<ScriptEngine> strongEngine = theEngine.toStrongRef();
1092 if (strongEngine) {1058 if (strongEngine) {
1093 qDebug() << "ScriptCache::getScriptContents() returned ScriptEngine still active calling ... entityScriptContentAvailable()";1059#ifdef THREAD_DEBUGGING
1094#if 1//def THREAD_DEBUGGING
1095 qDebug() << "ScriptEngine::entityScriptContentAvailable() IN LAMBDA contentAvailable on thread ["1060 qDebug() << "ScriptEngine::entityScriptContentAvailable() IN LAMBDA contentAvailable on thread ["
1096 << QThread::currentThread() << "] expected thread [" << strongEngine->thread() << "]";1061 << QThread::currentThread() << "] expected thread [" << strongEngine->thread() << "]";
1097#endif1062#endif
1098
1099
1100 strongEngine->entityScriptContentAvailable(entityID, scriptOrURL, contents, isURL, success);1063 strongEngine->entityScriptContentAvailable(entityID, scriptOrURL, contents, isURL, success);
1101 } else {1064 } else {
1065 // FIXME - I'm leaving this in for testing, so that QA can confirm that sometimes the script contents
1066 // returns after the ScriptEngine has been deleted, we can remove this after QA verifies the
1067 // repro case.
1102 qDebug() << "ScriptCache::getScriptContents() returned after our ScriptEngine was deleted...";1068 qDebug() << "ScriptCache::getScriptContents() returned after our ScriptEngine was deleted...";
1103 }1069 }
1104 }, forceRedownload);1070 }, forceRedownload);