Simplified repeated #if-ery and entangled conditionals.

Three checks of the same #if managed to save repetition of (if I felt
charitable) three shared lines, compared to combining the three into
one, which leaves the code easier to read (and obviates the need for
one of the "shared" lines).  Split a long line while moving it.

Change-Id: I762d10ae1df1224c749206b8eb490bafd7ea4900
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@theqtcompany.com>
This commit is contained in:
Edward Welbourne 2016-03-08 13:29:01 +01:00 committed by The Qt Project
parent 2027c0b926
commit b366530f58

View File

@ -1746,10 +1746,8 @@ void QNetworkReplyHttpImplPrivate::_q_startOperation()
QMetaObject::invokeMethod(q, "_q_finished", synchronous ? Qt::DirectConnection : Qt::QueuedConnection); QMetaObject::invokeMethod(q, "_q_finished", synchronous ? Qt::DirectConnection : Qt::QueuedConnection);
return; return;
} }
#endif
if (!start(request)) { if (!start(request)) {
#ifndef QT_NO_BEARERMANAGEMENT
// backend failed to start because the session state is not Connected. // backend failed to start because the session state is not Connected.
// QNetworkAccessManager will call reply->backend->start() again for us when the session // QNetworkAccessManager will call reply->backend->start() again for us when the session
// state changes. // state changes.
@ -1771,21 +1769,21 @@ void QNetworkReplyHttpImplPrivate::_q_startOperation()
QMetaObject::invokeMethod(q, "_q_finished", synchronous ? Qt::DirectConnection : Qt::QueuedConnection); QMetaObject::invokeMethod(q, "_q_finished", synchronous ? Qt::DirectConnection : Qt::QueuedConnection);
return; return;
} }
} else if (session) {
QObject::connect(session.data(), SIGNAL(stateChanged(QNetworkSession::State)),
q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)),
Qt::QueuedConnection);
}
#else #else
if (!start(request)) {
qWarning("Backend start failed"); qWarning("Backend start failed");
QMetaObject::invokeMethod(q, "_q_error", synchronous ? Qt::DirectConnection : Qt::QueuedConnection, QMetaObject::invokeMethod(q, "_q_error", synchronous ? Qt::DirectConnection : Qt::QueuedConnection,
Q_ARG(QNetworkReply::NetworkError, QNetworkReply::UnknownNetworkError), Q_ARG(QNetworkReply::NetworkError, QNetworkReply::UnknownNetworkError),
Q_ARG(QString, QCoreApplication::translate("QNetworkReply", "backend start error."))); Q_ARG(QString, QCoreApplication::translate("QNetworkReply", "backend start error.")));
QMetaObject::invokeMethod(q, "_q_finished", synchronous ? Qt::DirectConnection : Qt::QueuedConnection); QMetaObject::invokeMethod(q, "_q_finished", synchronous ? Qt::DirectConnection : Qt::QueuedConnection);
return; return;
#endif
} else {
#ifndef QT_NO_BEARERMANAGEMENT
if (session)
QObject::connect(session.data(), SIGNAL(stateChanged(QNetworkSession::State)),
q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)), Qt::QueuedConnection);
#endif
} }
#endif // QT_NO_BEARERMANAGEMENT
if (synchronous) { if (synchronous) {
state = Finished; state = Finished;