History

Add "Reload" button associated with entity editor's script URL field

The Reload button re-downloads the script for both the editor and for everyone in the vicinity.

David Rowe committed 11 years ago

Commit 6623d0c1 parent 672063318 files · +93 −33Browse files

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

Unified · Split

libraries/script-engine/src/ScriptCache.cpp+5−5
@@ -27,11 +27,11 @@ ScriptCache::ScriptCache(QObject* parent) { · 26 unmodified lines
27 // nothing to do here...27 // nothing to do here...
28}28}
29 29
30QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& isPending, bool redownload) {30QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& isPending, bool reload) {
31 assert(!_scriptCache.contains(url) || !redownload);31 assert(!_scriptCache.contains(url) || !reload);
32 32
33 QString scriptContents;33 QString scriptContents;
34 if (_scriptCache.contains(url)) {34 if (_scriptCache.contains(url) && !reload) {
35 qCDebug(scriptengine) << "Found script in cache:" << url.toString();35 qCDebug(scriptengine) << "Found script in cache:" << url.toString();
36 scriptContents = _scriptCache[url];36 scriptContents = _scriptCache[url];
37 scriptUser->scriptContentsAvailable(url, scriptContents);37 scriptUser->scriptContentsAvailable(url, scriptContents);
@@ -47,8 +47,8 @@ QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& is · 9 unmodified lines
47 QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();47 QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
48 QNetworkRequest networkRequest = QNetworkRequest(url);48 QNetworkRequest networkRequest = QNetworkRequest(url);
49 networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);49 networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
50 if (redownload) {50 if (reload) {
51 networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork);51 networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
52 qCDebug(scriptengine) << "Redownloading script at:" << url.toString();52 qCDebug(scriptengine) << "Redownloading script at:" << url.toString();
53 } else {53 } else {
54 qCDebug(scriptengine) << "Downloading script at:" << url.toString();54 qCDebug(scriptengine) << "Downloading script at:" << url.toString();