mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 13:49:46 +02:00
Merge pull request #4072 from Atlante45/network_replies_cleanup
Windows crash fix
This commit is contained in:
commit
285e588266
14 changed files with 45 additions and 6 deletions
|
@ -184,6 +184,7 @@ void Agent::run() {
|
||||||
loop.exec();
|
loop.exec();
|
||||||
|
|
||||||
QString scriptContents(reply->readAll());
|
QString scriptContents(reply->readAll());
|
||||||
|
delete reply;
|
||||||
|
|
||||||
qDebug() << "Downloaded script:" << scriptContents;
|
qDebug() << "Downloaded script:" << scriptContents;
|
||||||
|
|
||||||
|
|
|
@ -1736,6 +1736,9 @@ bool DomainServer::handleHTTPSRequest(HTTPSConnection* connection, const QUrl &u
|
||||||
connection->respond(HTTPConnection::StatusCode302, QByteArray(),
|
connection->respond(HTTPConnection::StatusCode302, QByteArray(),
|
||||||
HTTPConnection::DefaultContentType, cookieHeaders);
|
HTTPConnection::DefaultContentType, cookieHeaders);
|
||||||
|
|
||||||
|
delete tokenReply;
|
||||||
|
delete profileReply;
|
||||||
|
|
||||||
// we've redirected the user back to our homepage
|
// we've redirected the user back to our homepage
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -3770,9 +3770,9 @@ void Application::parseVersionXml() {
|
||||||
QString latestVersion;
|
QString latestVersion;
|
||||||
QUrl downloadUrl;
|
QUrl downloadUrl;
|
||||||
QString releaseNotes("Unavailable");
|
QString releaseNotes("Unavailable");
|
||||||
QObject* sender = QObject::sender();
|
QNetworkReply* sender = qobject_cast<QNetworkReply*>(QObject::sender());
|
||||||
|
|
||||||
QXmlStreamReader xml(qobject_cast<QNetworkReply*>(sender));
|
QXmlStreamReader xml(sender);
|
||||||
|
|
||||||
while (!xml.atEnd() && !xml.hasError()) {
|
while (!xml.atEnd() && !xml.hasError()) {
|
||||||
if (xml.tokenType() == QXmlStreamReader::StartElement && xml.name() == operatingSystem) {
|
if (xml.tokenType() == QXmlStreamReader::StartElement && xml.name() == operatingSystem) {
|
||||||
|
|
|
@ -158,6 +158,8 @@ void ScriptEditorWidget::loadFile(const QString& scriptPath) {
|
||||||
QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
QObject::connect(reply, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
||||||
loop.exec();
|
loop.exec();
|
||||||
_scriptEditorWidgetUI->scriptEdit->setPlainText(reply->readAll());
|
_scriptEditorWidgetUI->scriptEdit->setPlainText(reply->readAll());
|
||||||
|
delete reply;
|
||||||
|
|
||||||
if (!saveAs()) {
|
if (!saveAs()) {
|
||||||
static_cast<ScriptEditorWindow*>(this->parent()->parent()->parent())->terminateCurrentTab();
|
static_cast<ScriptEditorWindow*>(this->parent()->parent()->parent())->terminateCurrentTab();
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,6 +148,7 @@ void SnapshotShareDialog::postRequestFinished() {
|
||||||
|
|
||||||
QNetworkReply* requestReply = reinterpret_cast<QNetworkReply*>(sender());
|
QNetworkReply* requestReply = reinterpret_cast<QNetworkReply*>(sender());
|
||||||
QJsonDocument jsonResponse = QJsonDocument::fromJson(requestReply->readAll());
|
QJsonDocument jsonResponse = QJsonDocument::fromJson(requestReply->readAll());
|
||||||
|
requestReply->deleteLater();
|
||||||
const QJsonObject& responseObject = jsonResponse.object();
|
const QJsonObject& responseObject = jsonResponse.object();
|
||||||
|
|
||||||
if (responseObject.contains("id")) {
|
if (responseObject.contains("id")) {
|
||||||
|
|
|
@ -205,6 +205,7 @@ void BillboardOverlay::replyFinished() {
|
||||||
QNetworkReply* reply = static_cast<QNetworkReply*>(sender());
|
QNetworkReply* reply = static_cast<QNetworkReply*>(sender());
|
||||||
_billboard = reply->readAll();
|
_billboard = reply->readAll();
|
||||||
_isLoaded = true;
|
_isLoaded = true;
|
||||||
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BillboardOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
bool BillboardOverlay::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||||
|
|
|
@ -66,6 +66,7 @@ void ImageOverlay::replyFinished() {
|
||||||
_textureImage.loadFromData(rawData);
|
_textureImage.loadFromData(rawData);
|
||||||
_renderImage = true;
|
_renderImage = true;
|
||||||
_isLoaded = true;
|
_isLoaded = true;
|
||||||
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageOverlay::render(RenderArgs* args) {
|
void ImageOverlay::render(RenderArgs* args) {
|
||||||
|
|
|
@ -80,6 +80,7 @@ void Sound::downloadFinished(QNetworkReply* reply) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_isReady = true;
|
_isReady = true;
|
||||||
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::downSample(const QByteArray& rawAudioByteArray) {
|
void Sound::downSample(const QByteArray& rawAudioByteArray) {
|
||||||
|
|
|
@ -145,6 +145,7 @@ QString EntityTreeRenderer::loadScriptContents(const QString& scriptMaybeURLorTe
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "ERROR Loading file:" << url.toString();
|
qDebug() << "ERROR Loading file:" << url.toString();
|
||||||
}
|
}
|
||||||
|
delete reply;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,6 +240,7 @@ void DomainHandler::settingsRequestFinished() {
|
||||||
requestDomainSettings();
|
requestDomainSettings();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
settingsReply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DomainHandler::parseDTLSRequirementPacket(const QByteArray& dtlsRequirementPacket) {
|
void DomainHandler::parseDTLSRequirementPacket(const QByteArray& dtlsRequirementPacket) {
|
||||||
|
|
|
@ -67,13 +67,27 @@ QSharedPointer<Resource> ResourceCache::getResource(const QUrl& url, const QUrl&
|
||||||
_resources.insert(url, resource);
|
_resources.insert(url, resource);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_unusedResources.remove(resource->getLRUKey());
|
removeUnusedResource(resource);
|
||||||
}
|
}
|
||||||
return resource;
|
return resource;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceCache::addUnusedResource(const QSharedPointer<Resource>& resource) {
|
void ResourceCache::addUnusedResource(const QSharedPointer<Resource>& resource) {
|
||||||
|
static const int BYTES_PER_MEGABYTES = 1024 * 1024;
|
||||||
const int RETAINED_RESOURCE_COUNT = 50;
|
const int RETAINED_RESOURCE_COUNT = 50;
|
||||||
|
const int RETAINED_RESOURCE_SIZE = 100 * BYTES_PER_MEGABYTES;
|
||||||
|
|
||||||
|
while (_unusedResourcesTotalBytes + resource->getBytesTotal() > RETAINED_RESOURCE_SIZE &&
|
||||||
|
!_unusedResources.empty()) {
|
||||||
|
// unload the oldest resource
|
||||||
|
QMap<int, QSharedPointer<Resource> >::iterator it = _unusedResources.begin();
|
||||||
|
|
||||||
|
_unusedResourcesTotalBytes -= it.value()->getBytesTotal();
|
||||||
|
it.value()->setCache(NULL);
|
||||||
|
_unusedResources.erase(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (_unusedResources.size() > RETAINED_RESOURCE_COUNT) {
|
if (_unusedResources.size() > RETAINED_RESOURCE_COUNT) {
|
||||||
// unload the oldest resource
|
// unload the oldest resource
|
||||||
QMap<int, QSharedPointer<Resource> >::iterator it = _unusedResources.begin();
|
QMap<int, QSharedPointer<Resource> >::iterator it = _unusedResources.begin();
|
||||||
|
@ -82,6 +96,14 @@ void ResourceCache::addUnusedResource(const QSharedPointer<Resource>& resource)
|
||||||
}
|
}
|
||||||
resource->setLRUKey(++_lastLRUKey);
|
resource->setLRUKey(++_lastLRUKey);
|
||||||
_unusedResources.insert(resource->getLRUKey(), resource);
|
_unusedResources.insert(resource->getLRUKey(), resource);
|
||||||
|
_unusedResourcesTotalBytes += resource->getBytesTotal();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourceCache::removeUnusedResource(const QSharedPointer<Resource>& resource) {
|
||||||
|
if (_unusedResources.contains(resource->getLRUKey())) {
|
||||||
|
_unusedResources.remove(resource->getLRUKey());
|
||||||
|
_unusedResourcesTotalBytes -= resource->getBytesTotal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceCache::attemptRequest(Resource* resource) {
|
void ResourceCache::attemptRequest(Resource* resource) {
|
||||||
|
|
|
@ -45,7 +45,8 @@ public:
|
||||||
void refresh(const QUrl& url);
|
void refresh(const QUrl& url);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
qint64 _unusedResourcesTotalBytes = 0;
|
||||||
QMap<int, QSharedPointer<Resource> > _unusedResources;
|
QMap<int, QSharedPointer<Resource> > _unusedResources;
|
||||||
|
|
||||||
/// Loads a resource from the specified URL.
|
/// Loads a resource from the specified URL.
|
||||||
|
@ -58,8 +59,9 @@ protected:
|
||||||
/// Creates a new resource.
|
/// Creates a new resource.
|
||||||
virtual QSharedPointer<Resource> createResource(const QUrl& url,
|
virtual QSharedPointer<Resource> createResource(const QUrl& url,
|
||||||
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra) = 0;
|
const QSharedPointer<Resource>& fallback, bool delayLoad, const void* extra) = 0;
|
||||||
|
|
||||||
void addUnusedResource(const QSharedPointer<Resource>& resource);
|
void addUnusedResource(const QSharedPointer<Resource>& resource);
|
||||||
|
void removeUnusedResource(const QSharedPointer<Resource>& resource);
|
||||||
|
|
||||||
static void attemptRequest(Resource* resource);
|
static void attemptRequest(Resource* resource);
|
||||||
static void requestCompleted(Resource* resource);
|
static void requestCompleted(Resource* resource);
|
||||||
|
|
|
@ -194,6 +194,8 @@ void ScriptEngine::handleScriptDownload() {
|
||||||
qDebug() << "ERROR Loading file:" << reply->url().toString();
|
qDebug() << "ERROR Loading file:" << reply->url().toString();
|
||||||
emit errorLoadingScript(_fileNameString);
|
emit errorLoadingScript(_fileNameString);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reply->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptEngine::init() {
|
void ScriptEngine::init() {
|
||||||
|
@ -605,6 +607,7 @@ void ScriptEngine::include(const QString& includeFile) {
|
||||||
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit()));
|
||||||
loop.exec();
|
loop.exec();
|
||||||
includeContents = reply->readAll();
|
includeContents = reply->readAll();
|
||||||
|
reply->deleteLater();
|
||||||
} else {
|
} else {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
QString fileName = url.toString();
|
QString fileName = url.toString();
|
||||||
|
|
|
@ -332,7 +332,7 @@ void XMLHttpRequestClass::abortRequest() {
|
||||||
if (_reply) {
|
if (_reply) {
|
||||||
disconnectFromReply(_reply);
|
disconnectFromReply(_reply);
|
||||||
_reply->abort();
|
_reply->abort();
|
||||||
delete _reply;
|
_reply->deleteLater();
|
||||||
_reply = NULL;
|
_reply = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue