Qt: connect compat error handling to error signal

This commit is contained in:
Megamouse 2019-10-23 01:18:13 +02:00
parent 59747fd708
commit 200162cf2a

View file

@ -164,9 +164,22 @@ void game_compatibility::RequestCompatibility(bool online)
m_progress_dialog->setValue(bytesReceived); m_progress_dialog->setValue(bytesReceived);
}); });
// Handle response according to its contents // Handle network error
connect(network_reply, &QNetworkReply::finished, [=]() connect(network_reply, QOverload<QNetworkReply::NetworkError>::of(&QNetworkReply::error), [=](QNetworkReply::NetworkError error)
{ {
if (error == QNetworkReply::NoError)
{
return;
}
if (error != QNetworkReply::OperationCanceledError)
{
// We failed to retrieve a new database, therefore refresh gamelist to old state
const QString error = network_reply->errorString();
Q_EMIT DownloadError(error);
LOG_ERROR(GENERAL, "Compatibility error: { Network Error - %s }", sstr(error));
}
// Clean up Progress Dialog // Clean up Progress Dialog
if (m_progress_dialog) if (m_progress_dialog)
{ {
@ -177,20 +190,25 @@ void game_compatibility::RequestCompatibility(bool online)
m_progress_timer->stop(); m_progress_timer->stop();
} }
// Handle Errors network_reply->deleteLater();
if (network_reply->error() == QNetworkReply::OperationCanceledError) });
// Handle response according to its contents
connect(network_reply, &QNetworkReply::finished, [=]()
{
if (network_reply->error() != QNetworkReply::NoError)
{ {
network_reply->deleteLater();
return; return;
} }
else if (network_reply->error() != QNetworkReply::NoError)
// Clean up Progress Dialog
if (m_progress_dialog)
{ {
// We failed to retrieve a new database, therefore refresh gamelist to old state m_progress_dialog->close();
QString error = network_reply->errorString(); }
network_reply->deleteLater(); if (m_progress_timer)
Q_EMIT DownloadError(error); {
LOG_ERROR(GENERAL, "Compatibility error: { Network Error - %s }", sstr(error)); m_progress_timer->stop();
return;
} }
LOG_NOTICE(GENERAL, "Compatibility notice: { Database download finished }"); LOG_NOTICE(GENERAL, "Compatibility notice: { Database download finished }");