Commit 1be6e139 authored by Volker Krause's avatar Volker Krause

Clean up QNetworkReplies correctly

parent ef010f9b
...@@ -39,6 +39,7 @@ HandshakeJob::HandshakeJob(RESTClient* restClient, QObject* parent) ...@@ -39,6 +39,7 @@ HandshakeJob::HandshakeJob(RESTClient* restClient, QObject* parent)
} else { } else {
emitError(reply->errorString()); emitError(reply->errorString());
} }
reply->deleteLater();
}); });
connect(reply, &QNetworkReply::redirected, this, [this, reply](const auto &url) { connect(reply, &QNetworkReply::redirected, this, [this, reply](const auto &url) {
auto s = m_restClient->serverInfo(); auto s = m_restClient->serverInfo();
......
...@@ -34,6 +34,7 @@ ProductExportJob::ProductExportJob(const QString& productId, const QString& dest ...@@ -34,6 +34,7 @@ ProductExportJob::ProductExportJob(const QString& productId, const QString& dest
Q_ASSERT(m_restClient->isConnected()); Q_ASSERT(m_restClient->isConnected());
auto reply = RESTApi::listProducts(restClient); auto reply = RESTApi::listProducts(restClient);
connect(reply, &QNetworkReply::finished, this, [this, productId, reply]() { connect(reply, &QNetworkReply::finished, this, [this, productId, reply]() {
reply->deleteLater();
if (reply->error() != QNetworkReply::NoError) { if (reply->error() != QNetworkReply::NoError) {
deleteLater(); deleteLater();
return; return;
...@@ -82,6 +83,7 @@ void ProductExportJob::doExportSurveys() ...@@ -82,6 +83,7 @@ void ProductExportJob::doExportSurveys()
{ {
auto reply = RESTApi::listSurveys(m_restClient, m_product); auto reply = RESTApi::listSurveys(m_restClient, m_product);
connect(reply, &QNetworkReply::finished, this, [this, reply]() { connect(reply, &QNetworkReply::finished, this, [this, reply]() {
reply->deleteLater();
if (reply->error() != QNetworkReply::NoError) { if (reply->error() != QNetworkReply::NoError) {
deleteLater(); deleteLater();
return; return;
...@@ -101,6 +103,7 @@ void ProductExportJob::doExportData() ...@@ -101,6 +103,7 @@ void ProductExportJob::doExportData()
{ {
auto reply = RESTApi::listSamples(m_restClient, m_product); auto reply = RESTApi::listSamples(m_restClient, m_product);
connect(reply, &QNetworkReply::finished, this, [this, reply]() { connect(reply, &QNetworkReply::finished, this, [this, reply]() {
reply->deleteLater();
if (reply->error() != QNetworkReply::NoError) { if (reply->error() != QNetworkReply::NoError) {
deleteLater(); deleteLater();
return; return;
......
...@@ -59,6 +59,7 @@ void ProductImportJob::doImportSchema() ...@@ -59,6 +59,7 @@ void ProductImportJob::doImportSchema()
auto reply = RESTApi::createProduct(m_restClient, m_product); auto reply = RESTApi::createProduct(m_restClient, m_product);
connect(reply, &QNetworkReply::finished, this, [this, reply]() { connect(reply, &QNetworkReply::finished, this, [this, reply]() {
reply->deleteLater();
if (reply->error() != QNetworkReply::NoError) { if (reply->error() != QNetworkReply::NoError) {
deleteLater(); deleteLater();
return; return;
...@@ -86,6 +87,7 @@ void ProductImportJob::doImportSurveys() ...@@ -86,6 +87,7 @@ void ProductImportJob::doImportSurveys()
++m_jobCount; ++m_jobCount;
auto reply = RESTApi::createSurvey(m_restClient, m_product, s); auto reply = RESTApi::createSurvey(m_restClient, m_product, s);
connect(reply, &QNetworkReply::finished, this, [this, reply]() { connect(reply, &QNetworkReply::finished, this, [this, reply]() {
reply->deleteLater();
--m_jobCount; --m_jobCount;
if (reply->error() != QNetworkReply::NoError) { if (reply->error() != QNetworkReply::NoError) {
deleteLater(); deleteLater();
...@@ -114,6 +116,7 @@ void ProductImportJob::doImportData() ...@@ -114,6 +116,7 @@ void ProductImportJob::doImportData()
auto reply = RESTApi::addSamples(m_restClient, m_product, samples); auto reply = RESTApi::addSamples(m_restClient, m_product, samples);
connect(reply, &QNetworkReply::finished, this, [this, reply]() { connect(reply, &QNetworkReply::finished, this, [this, reply]() {
reply->deleteLater();
if (reply->error() == QNetworkReply::NoError) if (reply->error() == QNetworkReply::NoError)
emitFinished(); emitFinished();
}); });
......
...@@ -241,6 +241,7 @@ void MainWindow::createProduct() ...@@ -241,6 +241,7 @@ void MainWindow::createProduct()
auto reply = RESTApi::createProduct(m_restClient, product); auto reply = RESTApi::createProduct(m_restClient, product);
connect(reply, &QNetworkReply::finished, this, [this, reply, name]() { connect(reply, &QNetworkReply::finished, this, [this, reply, name]() {
reply->deleteLater();
if (reply->error() == QNetworkReply::NoError) { if (reply->error() == QNetworkReply::NoError) {
logMessage(QString::fromUtf8(reply->readAll())); logMessage(QString::fromUtf8(reply->readAll()));
m_productModel->reload(); m_productModel->reload();
...@@ -262,6 +263,7 @@ void MainWindow::deleteProduct() ...@@ -262,6 +263,7 @@ void MainWindow::deleteProduct()
auto reply = RESTApi::deleteProduct(m_restClient, product); auto reply = RESTApi::deleteProduct(m_restClient, product);
connect(reply, &QNetworkReply::finished, this, [this, reply]() { connect(reply, &QNetworkReply::finished, this, [this, reply]() {
reply->deleteLater();
if (reply->error() == QNetworkReply::NoError) { if (reply->error() == QNetworkReply::NoError) {
logMessage(QString::fromUtf8(reply->readAll())); logMessage(QString::fromUtf8(reply->readAll()));
} }
......
...@@ -117,6 +117,7 @@ void DataModel::reload() ...@@ -117,6 +117,7 @@ void DataModel::reload()
const auto samples = Sample::fromJson(reply->readAll(), m_product); const auto samples = Sample::fromJson(reply->readAll(), m_product);
setSamples(samples); setSamples(samples);
} }
reply->deleteLater();
}); });
} }
......
...@@ -61,6 +61,7 @@ void ProductModel::reload() ...@@ -61,6 +61,7 @@ void ProductModel::reload()
auto json = reply->readAll(); auto json = reply->readAll();
mergeProducts(Product::fromJson(json)); mergeProducts(Product::fromJson(json));
} }
reply->deleteLater();
}); });
} }
......
...@@ -59,6 +59,7 @@ void SurveyModel::reload() ...@@ -59,6 +59,7 @@ void SurveyModel::reload()
m_surveys = Survey::fromJson(data); m_surveys = Survey::fromJson(data);
endResetModel(); endResetModel();
} }
reply->deleteLater();
}); });
} }
...@@ -107,6 +108,7 @@ bool SurveyModel::setData(const QModelIndex &index, const QVariant &value, int r ...@@ -107,6 +108,7 @@ bool SurveyModel::setData(const QModelIndex &index, const QVariant &value, int r
reload(); reload();
}); });
emit dataChanged(index, index); emit dataChanged(index, index);
reply->deleteLater();
return true; return true;
} }
return false; return false;
......
...@@ -121,6 +121,7 @@ void SchemaEditor::save() ...@@ -121,6 +121,7 @@ void SchemaEditor::save()
setDirty(false); setDirty(false);
emit logMessage(QString::fromUtf8((reply->readAll()))); emit logMessage(QString::fromUtf8((reply->readAll())));
emit productChanged(product()); emit productChanged(product());
reply->deleteLater();
}); });
} }
......
...@@ -77,6 +77,7 @@ void SurveyEditor::createSurvey() ...@@ -77,6 +77,7 @@ void SurveyEditor::createSurvey()
emit logMessage(QString::fromUtf8(reply->readAll())); emit logMessage(QString::fromUtf8(reply->readAll()));
} }
m_surveyModel->reload(); m_surveyModel->reload();
reply->deleteLater();
}); });
} }
...@@ -100,6 +101,7 @@ void SurveyEditor::editSurvey() ...@@ -100,6 +101,7 @@ void SurveyEditor::editSurvey()
return; return;
emit logMessage(QString::fromUtf8(reply->readAll())); emit logMessage(QString::fromUtf8(reply->readAll()));
m_surveyModel->reload(); m_surveyModel->reload();
reply->deleteLater();
}); });
} }
...@@ -126,6 +128,7 @@ void SurveyEditor::deleteSurvey() ...@@ -126,6 +128,7 @@ void SurveyEditor::deleteSurvey()
return; return;
emit logMessage(QString::fromUtf8(reply->readAll())); emit logMessage(QString::fromUtf8(reply->readAll()));
m_surveyModel->reload(); m_surveyModel->reload();
reply->deleteLater();
}); });
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment