Showing the changes to libraries/script-engine/src/ScriptCache.cpp (1 of 6 files). Show all
Unified · Split
| @@ -15,6 +15,7 @@ · 14 unmodified lines | ||
| 15 | 15 | #include <QNetworkConfiguration> |
| 16 | 16 | #include <QNetworkReply> |
| 17 | 17 | #include <QObject> |
| 18 | +#include <QThread> | |
| 18 | 19 | |
| 19 | 20 | #include <assert.h> |
| 20 | 21 | #include <SharedUtil.h> |
| @@ -42,7 +43,7 @@ QString ScriptCache::getScript(const QUrl& unnormalizedURL, ScriptUser* scriptUs · 21 unmodified lines | ||
| 42 | 43 | if (alreadyWaiting) { |
| 43 | 44 | qCDebug(scriptengine) << "Already downloading script at:" << url.toString(); |
| 44 | 45 | } else { |
| 45 | − auto request = ResourceManager::createResourceRequest(this, url); | |
| 46 | + auto request = ResourceManager::createResourceRequest(nullptr, url); | |
| 46 | 47 | request->setCacheEnabled(!reload); |
| 47 | 48 | connect(request, &ResourceRequest::finished, this, &ScriptCache::scriptDownloaded); |
| 48 | 49 | request->send(); |
| @@ -82,6 +83,9 @@ void ScriptCache::scriptDownloaded() { · 33 unmodified lines | ||
| 82 | 83 | } |
| 83 | 84 | |
| 84 | 85 | void ScriptCache::getScriptContents(const QString& scriptOrURL, contentAvailableCallback contentAvailable, bool forceDownload) { |
| 86 | + #ifdef THREAD_DEBUGGING | |
| 87 | + qCDebug(scriptengine) << "ScriptCache::getScriptContents() on thread [" << QThread::currentThread() << "] expected thread [" << thread() << "]"; | |
| 88 | + #endif | |
| 85 | 89 | QUrl unnormalizedURL(scriptOrURL); |
| 86 | 90 | QUrl url = ResourceManager::normalizeURL(unnormalizedURL); |
| 87 | 91 | |
| @@ -93,6 +97,9 @@ void ScriptCache::getScriptContents(const QString& scriptOrURL, contentAvailable · 5 unmodified lines | ||
| 93 | 97 | |
| 94 | 98 | if (_scriptCache.contains(url) && !forceDownload) { |
| 95 | 99 | qCDebug(scriptengine) << "Found script in cache:" << url.toString(); |
| 100 | + #if 1 // def THREAD_DEBUGGING | |
| 101 | + qCDebug(scriptengine) << "ScriptCache::getScriptContents() about to call contentAvailable() on thread [" << QThread::currentThread() << "] expected thread [" << thread() << "]"; | |
| 102 | + #endif | |
| 96 | 103 | contentAvailable(url.toString(), _scriptCache[url], true, true); |
| 97 | 104 | } else { |
| 98 | 105 | bool alreadyWaiting = _contentCallbacks.contains(url); |
| @@ -101,7 +108,10 @@ void ScriptCache::getScriptContents(const QString& scriptOrURL, contentAvailable · 2 unmodified lines | ||
| 101 | 108 | if (alreadyWaiting) { |
| 102 | 109 | qCDebug(scriptengine) << "Already downloading script at:" << url.toString(); |
| 103 | 110 | } else { |
| 104 | − auto request = ResourceManager::createResourceRequest(this, url); | |
| 111 | + #ifdef THREAD_DEBUGGING | |
| 112 | + qCDebug(scriptengine) << "about to call: ResourceManager::createResourceRequest(this, url); on thread [" << QThread::currentThread() << "] expected thread [" << thread() << "]"; | |
| 113 | + #endif | |
| 114 | + auto request = ResourceManager::createResourceRequest(nullptr, url); | |
| 105 | 115 | request->setCacheEnabled(!forceDownload); |
| 106 | 116 | connect(request, &ResourceRequest::finished, this, &ScriptCache::scriptContentAvailable); |
| 107 | 117 | request->send(); |
| @@ -110,6 +120,9 @@ void ScriptCache::getScriptContents(const QString& scriptOrURL, contentAvailable · 2 unmodified lines | ||
| 110 | 120 | } |
| 111 | 121 | |
| 112 | 122 | void ScriptCache::scriptContentAvailable() { |
| 123 | + #ifdef THREAD_DEBUGGING | |
| 124 | + qCDebug(scriptengine) << "ScriptCache::scriptContentAvailable() on thread [" << QThread::currentThread() << "] expected thread [" << thread() << "]"; | |
| 125 | + #endif | |
| 113 | 126 | ResourceRequest* req = qobject_cast<ResourceRequest*>(sender()); |
| 114 | 127 | QUrl url = req->getUrl(); |
| 115 | 128 | QList<contentAvailableCallback> allCallbacks = _contentCallbacks.values(url); |