mirror of
https://github.com/overte-org/overte.git
synced 2025-04-20 12:04:18 +02:00
Re-download scripts upon Reload All
This commit is contained in:
parent
2ab3f42c6a
commit
f220d40bb8
3 changed files with 12 additions and 1 deletions
|
@ -4344,6 +4344,8 @@ void Application::scriptFinished(const QString& scriptName) {
|
|||
}
|
||||
|
||||
void Application::stopAllScripts(bool restart) {
|
||||
auto scriptCache = DependencyManager::get<ScriptCache>();
|
||||
|
||||
// stops all current running scripts
|
||||
for (QHash<QString, ScriptEngine*>::const_iterator it = _scriptEnginesHash.constBegin();
|
||||
it != _scriptEnginesHash.constEnd(); it++) {
|
||||
|
@ -4351,6 +4353,7 @@ void Application::stopAllScripts(bool restart) {
|
|||
continue;
|
||||
}
|
||||
if (restart && it.value()->isUserLoaded()) {
|
||||
scriptCache->deleteScript(it.key());
|
||||
connect(it.value(), SIGNAL(finished(const QString&)), SLOT(loadScript(const QString&)));
|
||||
}
|
||||
it.value()->stop();
|
||||
|
|
|
@ -44,7 +44,7 @@ QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& is
|
|||
QNetworkRequest networkRequest = QNetworkRequest(url);
|
||||
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
||||
|
||||
qCDebug(scriptengine) << "Downloading script at" << url.toString();
|
||||
qCDebug(scriptengine) << "Downloading script at:" << url.toString();
|
||||
QNetworkReply* reply = networkAccessManager.get(networkRequest);
|
||||
connect(reply, &QNetworkReply::finished, this, &ScriptCache::scriptDownloaded);
|
||||
}
|
||||
|
@ -52,6 +52,13 @@ QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& is
|
|||
return scriptContents;
|
||||
}
|
||||
|
||||
void ScriptCache::deleteScript(const QUrl& url) {
|
||||
if (_scriptCache.contains(url)) {
|
||||
qCDebug(scriptengine) << "Delete script from cache:" << url.toString();
|
||||
_scriptCache.remove(url);
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptCache::scriptDownloaded() {
|
||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
|
||||
QUrl url = reply->url();
|
||||
|
|
|
@ -27,6 +27,7 @@ class ScriptCache : public QObject, public Dependency {
|
|||
|
||||
public:
|
||||
QString getScript(const QUrl& url, ScriptUser* scriptUser, bool& isPending);
|
||||
void deleteScript(const QUrl& url);
|
||||
void addScriptToBadScriptList(const QUrl& url) { _badScripts.insert(url); }
|
||||
bool isInBadScriptList(const QUrl& url) { return _badScripts.contains(url); }
|
||||
|
||||
|
|
Loading…
Reference in a new issue