mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:18:38 +02:00
add error log debug for script fail
This commit is contained in:
parent
6419a148d4
commit
e462617a6b
1 changed files with 8 additions and 5 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkConfiguration>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& is
|
||||||
isPending = true;
|
isPending = true;
|
||||||
bool alreadyWaiting = _scriptUsers.contains(url);
|
bool alreadyWaiting = _scriptUsers.contains(url);
|
||||||
_scriptUsers.insert(url, scriptUser);
|
_scriptUsers.insert(url, scriptUser);
|
||||||
|
|
||||||
if (alreadyWaiting) {
|
if (alreadyWaiting) {
|
||||||
qCDebug(scriptengine) << "Already downloading script at:" << url.toString();
|
qCDebug(scriptengine) << "Already downloading script at:" << url.toString();
|
||||||
} else {
|
} else {
|
||||||
|
@ -43,7 +44,7 @@ QString ScriptCache::getScript(const QUrl& url, ScriptUser* scriptUser, bool& is
|
||||||
QNetworkRequest networkRequest = QNetworkRequest(url);
|
QNetworkRequest networkRequest = QNetworkRequest(url);
|
||||||
networkRequest.setHeader(QNetworkRequest::UserAgentHeader, HIGH_FIDELITY_USER_AGENT);
|
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);
|
QNetworkReply* reply = networkAccessManager.get(networkRequest);
|
||||||
connect(reply, &QNetworkReply::finished, this, &ScriptCache::scriptDownloaded);
|
connect(reply, &QNetworkReply::finished, this, &ScriptCache::scriptDownloaded);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +57,7 @@ void ScriptCache::scriptDownloaded() {
|
||||||
QUrl url = reply->url();
|
QUrl url = reply->url();
|
||||||
QList<ScriptUser*> scriptUsers = _scriptUsers.values(url);
|
QList<ScriptUser*> scriptUsers = _scriptUsers.values(url);
|
||||||
_scriptUsers.remove(url);
|
_scriptUsers.remove(url);
|
||||||
|
|
||||||
if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) {
|
if (reply->error() == QNetworkReply::NoError && reply->attribute(QNetworkRequest::HttpStatusCodeAttribute) == 200) {
|
||||||
_scriptCache[url] = reply->readAll();
|
_scriptCache[url] = reply->readAll();
|
||||||
qCDebug(scriptengine) << "Done downloading script at:" << url.toString();
|
qCDebug(scriptengine) << "Done downloading script at:" << url.toString();
|
||||||
|
@ -65,7 +66,9 @@ void ScriptCache::scriptDownloaded() {
|
||||||
user->scriptContentsAvailable(url, _scriptCache[url]);
|
user->scriptContentsAvailable(url, _scriptCache[url]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qCDebug(scriptengine) << "ERROR Loading file:" << reply->url().toString();
|
qCWarning(scriptengine) << "Error loading script from URL " << reply->url().toString()
|
||||||
|
<< "- HTTP status code is" << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()
|
||||||
|
<< "and error from QNetworkReply is" << reply->errorString();
|
||||||
foreach(ScriptUser* user, scriptUsers) {
|
foreach(ScriptUser* user, scriptUsers) {
|
||||||
user->errorInLoadingScript(url);
|
user->errorInLoadingScript(url);
|
||||||
}
|
}
|
||||||
|
@ -73,4 +76,4 @@ void ScriptCache::scriptDownloaded() {
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue