Showing the changes to libraries/script-engine/src/ScriptCache.cpp (1 of 2 files). Show all
Unified · Split
| @@ -9,6 +9,8 @@ · 8 unmodified lines | ||
| 9 | 9 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 10 | 10 | // |
| 11 | 11 | |
| 12 | +#include "ScriptCache.h" | |
| 13 | + | |
| 12 | 14 | #include <QCoreApplication> |
| 13 | 15 | #include <QEventLoop> |
| 14 | 16 | #include <QNetworkAccessManager> |
| @@ -20,7 +22,7 @@ · 5 unmodified lines | ||
| 20 | 22 | #include <assert.h> |
| 21 | 23 | #include <SharedUtil.h> |
| 22 | 24 | |
| 23 | −#include "ScriptCache.h" | |
| 25 | +#include "ScriptEngines.h" | |
| 24 | 26 | #include "ScriptEngineLogging.h" |
| 25 | 27 | |
| 26 | 28 | ScriptCache::ScriptCache(QObject* parent) { |
| @@ -78,22 +80,25 @@ void ScriptCache::scriptDownloaded() { · 51 unmodified lines | ||
| 78 | 80 | QList<ScriptUser*> scriptUsers = _scriptUsers.values(url); |
| 79 | 81 | _scriptUsers.remove(url); |
| 80 | 82 | |
| 81 | − if (req->getResult() == ResourceRequest::Success) { | |
| 82 | − auto scriptContents = req->getData(); | |
| 83 | − _scriptCache[url] = scriptContents; | |
| 84 | − lock.unlock(); | |
| 85 | − qCDebug(scriptengine) << "Done downloading script at:" << url.toString(); | |
| 83 | + if (!DependencyManager::get<ScriptEngines>()->isStopped()) { | |
| 84 | + if (req->getResult() == ResourceRequest::Success) { | |
| 85 | + auto scriptContents = req->getData(); | |
| 86 | + _scriptCache[url] = scriptContents; | |
| 87 | + lock.unlock(); | |
| 88 | + qCDebug(scriptengine) << "Done downloading script at:" << url.toString(); | |
| 86 | 89 | |
| 87 | − foreach(ScriptUser* user, scriptUsers) { | |
| 88 | − user->scriptContentsAvailable(url, scriptContents); | |
| 89 | − } | |
| 90 | − } else { | |
| 91 | − lock.unlock(); | |
| 92 | − qCWarning(scriptengine) << "Error loading script from URL " << url; | |
| 93 | − foreach(ScriptUser* user, scriptUsers) { | |
| 94 | − user->errorInLoadingScript(url); | |
| 90 | + foreach(ScriptUser* user, scriptUsers) { | |
| 91 | + user->scriptContentsAvailable(url, scriptContents); | |
| 92 | + } | |
| 93 | + } else { | |
| 94 | + lock.unlock(); | |
| 95 | + qCWarning(scriptengine) << "Error loading script from URL " << url; | |
| 96 | + foreach(ScriptUser* user, scriptUsers) { | |
| 97 | + user->errorInLoadingScript(url); | |
| 98 | + } | |
| 95 | 99 | } |
| 96 | 100 | } |
| 101 | + | |
| 97 | 102 | req->deleteLater(); |
| 98 | 103 | } |
| 99 | 104 | |
| @@ -162,9 +167,11 @@ void ScriptCache::scriptContentAvailable() { · 62 unmodified lines | ||
| 162 | 167 | } |
| 163 | 168 | } |
| 164 | 169 | |
| 165 | − foreach(contentAvailableCallback thisCallback, allCallbacks) { | |
| 166 | − thisCallback(url.toString(), scriptContent, true, success); | |
| 167 | − } | |
| 168 | 170 | req->deleteLater(); |
| 169 | −} | |
| 170 | 171 | |
| 172 | + if (!DependencyManager::get<ScriptEngines>()->isStopped()) { | |
| 173 | + foreach(contentAvailableCallback thisCallback, allCallbacks) { | |
| 174 | + thisCallback(url.toString(), scriptContent, true, success); | |
| 175 | + } | |
| 176 | + } | |
| 177 | +} | |