History

Make individual reload buttons reload scripts

David Rowe committed 11 years ago

Commit 67206331 parent 2a005868 files · +53 −30Browse files

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

Unified · Split

libraries/script-engine/src/ScriptCache.cpp+12−3
@@ -16,16 +16,20 @@ · 15 unmodified lines
16#include <QNetworkReply>16#include <QNetworkReply>
17#include <QObject>17#include <QObject>
18 18
19#include <assert.h>
19#include <NetworkAccessManager.h>20#include <NetworkAccessManager.h>
20#include <SharedUtil.h>21#include <SharedUtil.h>
21#include "ScriptEngineLogging.h"22
22#include "ScriptCache.h"23#include "ScriptCache.h"
24#include "ScriptEngineLogging.h"
23 25
24ScriptCache::ScriptCache(QObject* parent) {26ScriptCache::ScriptCache(QObject* parent) {
25 // nothing to do here...27 // nothing to do here...
26}28}
27 29
28QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& isPending) {30QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& isPending, bool redownload) {
31 assert(!_scriptCache.contains(url) || !redownload);
32
29 QString scriptContents;33 QString scriptContents;
30 if (_scriptCache.contains(url)) {34 if (_scriptCache.contains(url)) {
31 qCDebug(scriptengine) << "Found script in cache:" << url.toString();35 qCDebug(scriptengine) << "Found script in cache:" << url.toString();
@@ -43,8 +47,13 @@ QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& is · 11 unmodified lines
43 QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();47 QNetworkAccessManager& networkAccessManager = NetworkAccessManager::getInstance();
44 QNetworkRequest networkRequest = QNetworkRequest(url);48 QNetworkRequest networkRequest = QNetworkRequest(url);
45 networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);49 networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
50 if (redownload) {
51 networkRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork);
52 qCDebug(scriptengine) << "Redownloading script at:" << url.toString();
53 } else {
54 qCDebug(scriptengine) << "Downloading script at:" << url.toString();
55 }
46 56
47 qCDebug(scriptengine) << "Downloading script at:" << url.toString();
48 QNetworkReply* reply = networkAccessManager.get(networkRequest);57 QNetworkReply* reply = networkAccessManager.get(networkRequest);
49 connect(reply, &QNetworkReply::finished, this, &ScriptCache::scriptDownloaded);58 connect(reply, &QNetworkReply::finished, this, &ScriptCache::scriptDownloaded);
50 }59 }