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)
} else {
emitError(reply->errorString());
}
reply->deleteLater();
});
connect(reply, &QNetworkReply::redirected, this, [this, reply](const auto &url) {
auto s = m_restClient->serverInfo();
......
......@@ -34,6 +34,7 @@ ProductExportJob::ProductExportJob(const QString& productId, const QString& dest
Q_ASSERT(m_restClient->isConnected());
auto reply = RESTApi::listProducts(restClient);
connect(reply, &QNetworkReply::finished, this, [this, productId, reply]() {
reply->deleteLater();
if (reply->error() != QNetworkReply::NoError) {
deleteLater();
return;
......@@ -82,6 +83,7 @@ void ProductExportJob::doExportSurveys()
{
auto reply = RESTApi::listSurveys(m_restClient, m_product);
connect(reply, &QNetworkReply::finished, this, [this, reply]() {
reply->deleteLater();
if (reply->error() != QNetworkReply::NoError) {
deleteLater();
return;
......@@ -101,6 +103,7 @@ void ProductExportJob::doExportData()
{
auto reply = RESTApi::listSamples(m_restClient, m_product);
connect(reply, &QNetworkReply::finished, this, [this, reply]() {
reply->deleteLater();
if (reply->error() != QNetworkReply::NoError) {
deleteLater();
return;
......
......@@ -59,6 +59,7 @@ void ProductImportJob::doImportSchema()
auto reply = RESTApi::createProduct(m_restClient, m_product);
connect(reply, &QNetworkReply::finished, this, [this, reply]() {
reply->deleteLater();
if (reply->error() != QNetworkReply::NoError) {
deleteLater();
return;
......@@ -86,6 +87,7 @@ void ProductImportJob::doImportSurveys()
++m_jobCount;
auto reply = RESTApi::createSurvey(m_restClient, m_product, s);
connect(reply, &QNetworkReply::finished, this, [this, reply]() {
reply->deleteLater();
--m_jobCount;
if (reply->error() != QNetworkReply::NoError) {
deleteLater();
......@@ -114,6 +116,7 @@ void ProductImportJob::doImportData()
auto reply = RESTApi::addSamples(m_restClient, m_product, samples);
connect(reply, &QNetworkReply::finished, this, [this, reply]() {
reply->deleteLater();
if (reply->error() == QNetworkReply::NoError)
emitFinished();
});
......
......@@ -241,6 +241,7 @@ void MainWindow::createProduct()
auto reply = RESTApi::createProduct(m_restClient, product);
connect(reply, &QNetworkReply::finished, this, [this, reply, name]() {
reply->deleteLater();
if (reply->error() == QNetworkReply::NoError) {
logMessage(QString::fromUtf8(reply->readAll()));
m_productModel->reload();
......@@ -262,6 +263,7 @@ void MainWindow::deleteProduct()
auto reply = RESTApi::deleteProduct(m_restClient, product);
connect(reply, &QNetworkReply::finished, this, [this, reply]() {
reply->deleteLater();
if (reply->error() == QNetworkReply::NoError) {
logMessage(QString::fromUtf8(reply->readAll()));
}
......
......@@ -117,6 +117,7 @@ void DataModel::reload()
const auto samples = Sample::fromJson(reply->readAll(), m_product);
setSamples(samples);
}
reply->deleteLater();
});
}
......
......@@ -61,6 +61,7 @@ void ProductModel::reload()
auto json = reply->readAll();
mergeProducts(Product::fromJson(json));
}
reply->deleteLater();
});
}
......
......@@ -59,6 +59,7 @@ void SurveyModel::reload()
m_surveys = Survey::fromJson(data);
endResetModel();
}
reply->deleteLater();
});
}
......@@ -107,6 +108,7 @@ bool SurveyModel::setData(const QModelIndex &index, const QVariant &value, int r
reload();
});
emit dataChanged(index, index);
reply->deleteLater();
return true;
}
return false;
......
......@@ -121,6 +121,7 @@ void SchemaEditor::save()
setDirty(false);
emit logMessage(QString::fromUtf8((reply->readAll())));
emit productChanged(product());
reply->deleteLater();
});
}
......
......@@ -77,6 +77,7 @@ void SurveyEditor::createSurvey()
emit logMessage(QString::fromUtf8(reply->readAll()));
}
m_surveyModel->reload();
reply->deleteLater();
});
}
......@@ -100,6 +101,7 @@ void SurveyEditor::editSurvey()
return;
emit logMessage(QString::fromUtf8(reply->readAll()));
m_surveyModel->reload();
reply->deleteLater();
});
}
......@@ -126,6 +128,7 @@ void SurveyEditor::deleteSurvey()
return;
emit logMessage(QString::fromUtf8(reply->readAll()));
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