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
2727 // nothing to do here...
2828 }
2929
30−QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& isPending, bool redownload) {
31− assert(!_scriptCache.contains(url) || !redownload);
30+QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& isPending, bool reload) {
31+ assert(!_scriptCache.contains(url) || !reload);
3232
3333 QString scriptContents;
34− if (_scriptCache.contains(url)) {
34+ if (_scriptCache.contains(url) && !reload) {
3535 qCDebug(scriptengine) << "Found script in cache:" << url.toString();
3636 scriptContents = _scriptCache[url];
3737 scriptUser->scriptContentsAvailable(url, scriptContents);
@@ -47,8 +47,8 @@ QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& is · 9 unmodified lines
4747 QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
4848 QNetworkRequest networkRequest = QNetworkRequest(url);
4949 networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
50− if (redownload) {
51− networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork);
50+ if (reload) {
51+ networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
5252 qCDebug(scriptengine) << "Redownloading script at:" << url.toString();
5353 } else {
5454 qCDebug(scriptengine) << "Downloading script at:" << url.toString();