more correct error checking

This commit is contained in:
Evgenii Alekseev 2016-08-21 19:24:16 +03:00
parent 18c993c0d5
commit f3f9239984
4 changed files with 30 additions and 18 deletions

View File

@ -123,13 +123,19 @@ void AWDataEngineAggregator::createQueuedConnection()
sources = m_dataEngines[dataEngine]->sources();
// reconnect sources
for (auto source : sources) {
Plasma::DataContainer *container =m_dataEngines[dataEngine]->containerForSource(source);
Plasma::DataContainer *container
= m_dataEngines[dataEngine]->containerForSource(source);
// disconnect old connections first
disconnect(container, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)),
parent(), SLOT(dataUpdated(QString,Plasma::DataEngine::Data)));
disconnect(container,
SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)),
parent(),
SLOT(dataUpdated(QString, Plasma::DataEngine::Data)));
// and now reconnect with Qt::QueuedConnection type
connect(container, SIGNAL(dataUpdated(QString,Plasma::DataEngine::Data)),
parent(), SLOT(dataUpdated(QString,Plasma::DataEngine::Data)), Qt::QueuedConnection);
connect(container,
SIGNAL(dataUpdated(QString, Plasma::DataEngine::Data)),
parent(),
SLOT(dataUpdated(QString, Plasma::DataEngine::Data)),
Qt::QueuedConnection);
}
}
}

View File

@ -26,7 +26,6 @@
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QSettings>
#include <QtConcurrent/QtConcurrent>
#include "awdebug.h"
@ -145,13 +144,16 @@ void AWUpdateHelper::userReplyOnUpdates(QAbstractButton *button)
void AWUpdateHelper::versionReplyRecieved(QNetworkReply *reply,
const bool showAnyway)
{
qCDebug(LOG_AW) << "Return code" << reply->error() << "with message"
<< reply->errorString() << "and show anyway" << showAnyway;
qCDebug(LOG_AW) << "Show message anyway" << showAnyway;
if (reply->error() != QNetworkReply::NoError) {
qCWarning(LOG_AW) << "An error occurs" << reply->error()
<< "with message" << reply->errorString();
return;
}
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
if ((reply->error() != QNetworkReply::NoError)
|| (error.error != QJsonParseError::NoError)) {
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_AW) << "Parse error" << error.errorString();
return;
}

View File

@ -188,15 +188,17 @@ void ExtQuotes::writeConfiguration() const
void ExtQuotes::quotesReplyReceived(QNetworkReply *reply)
{
qCDebug(LOG_LIB) << "Return code" << reply->error() << "with message"
<< reply->errorString();
if (reply->error() != QNetworkReply::NoError) {
qCWarning(LOG_AW) << "An error occurs" << reply->error()
<< "with message" << reply->errorString();
return;
}
m_isRunning = false;
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
reply->deleteLater();
if ((reply->error() != QNetworkReply::NoError)
|| (error.error != QJsonParseError::NoError)) {
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
return;
}

View File

@ -336,15 +336,17 @@ void ExtWeather::writeConfiguration() const
void ExtWeather::weatherReplyReceived(QNetworkReply *reply)
{
qCDebug(LOG_LIB) << "Return code" << reply->error() << "with message"
<< reply->errorString();
if (reply->error() != QNetworkReply::NoError) {
qCWarning(LOG_AW) << "An error occurs" << reply->error()
<< "with message" << reply->errorString();
return;
}
m_isRunning = false;
QJsonParseError error;
QJsonDocument jsonDoc = QJsonDocument::fromJson(reply->readAll(), &error);
reply->deleteLater();
if ((reply->error() != QNetworkReply::NoError)
|| (error.error != QJsonParseError::NoError)) {
if (error.error != QJsonParseError::NoError) {
qCWarning(LOG_LIB) << "Parse error" << error.errorString();
return;
}