Avoid repetition of if-condition when aborting requests
This commit is contained in:
parent
2113dee0b9
commit
edceb2fddb
|
@ -312,6 +312,16 @@ void SyncthingConnection::disconnect()
|
||||||
abortAllRequests();
|
abortAllRequests();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Aborts the specified \a reply if it is not nullptr.
|
||||||
|
*/
|
||||||
|
static inline void abortMaybe(QNetworkReply *reply)
|
||||||
|
{
|
||||||
|
if (reply) {
|
||||||
|
reply->abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Aborts status-relevant, pending requests.
|
* \brief Aborts status-relevant, pending requests.
|
||||||
* \remarks Status-relevant means that requests for triggering actions like rescan() or restart() are excluded. requestQrCode() does not
|
* \remarks Status-relevant means that requests for triggering actions like rescan() or restart() are excluded. requestQrCode() does not
|
||||||
|
@ -320,36 +330,18 @@ void SyncthingConnection::disconnect()
|
||||||
void SyncthingConnection::abortAllRequests()
|
void SyncthingConnection::abortAllRequests()
|
||||||
{
|
{
|
||||||
m_connectionAborted = m_abortingAllRequests = true;
|
m_connectionAborted = m_abortingAllRequests = true;
|
||||||
if (m_configReply) {
|
abortMaybe(m_configReply);
|
||||||
m_configReply->abort();
|
abortMaybe(m_statusReply);
|
||||||
}
|
abortMaybe(m_connectionsReply);
|
||||||
if (m_statusReply) {
|
abortMaybe(m_errorsReply);
|
||||||
m_statusReply->abort();
|
abortMaybe(m_dirStatsReply);
|
||||||
}
|
abortMaybe(m_devStatsReply);
|
||||||
if (m_connectionsReply) {
|
abortMaybe(m_eventsReply);
|
||||||
m_connectionsReply->abort();
|
abortMaybe(m_versionReply);
|
||||||
}
|
abortMaybe(m_diskEventsReply);
|
||||||
if (m_errorsReply) {
|
abortMaybe(m_logReply);
|
||||||
m_errorsReply->abort();
|
abortMaybe(m_configReply);
|
||||||
}
|
abortMaybe(m_configReply);
|
||||||
if (m_dirStatsReply) {
|
|
||||||
m_dirStatsReply->abort();
|
|
||||||
}
|
|
||||||
if (m_devStatsReply) {
|
|
||||||
m_devStatsReply->abort();
|
|
||||||
}
|
|
||||||
if (m_eventsReply) {
|
|
||||||
m_eventsReply->abort();
|
|
||||||
}
|
|
||||||
if (m_versionReply) {
|
|
||||||
m_versionReply->abort();
|
|
||||||
}
|
|
||||||
if (m_diskEventsReply) {
|
|
||||||
m_diskEventsReply->abort();
|
|
||||||
}
|
|
||||||
if (m_logReply) {
|
|
||||||
m_logReply->abort();
|
|
||||||
}
|
|
||||||
for (auto *const reply : std::as_const(m_otherReplies)) {
|
for (auto *const reply : std::as_const(m_otherReplies)) {
|
||||||
reply->abort();
|
reply->abort();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue