From 11567218222c1632c34be892e0658c74dba510cc Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 26 Dec 2018 01:14:01 +0100 Subject: [PATCH] Ensure not to continue reconnecting while still aborting --- connector/syncthingconnection.cpp | 5 +++++ connector/syncthingconnection.h | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/connector/syncthingconnection.cpp b/connector/syncthingconnection.cpp index 43d26c2..44be974 100644 --- a/connector/syncthingconnection.cpp +++ b/connector/syncthingconnection.cpp @@ -66,6 +66,7 @@ SyncthingConnection::SyncthingConnection(const QString &syncthingUrl, const QByt , m_apiKey(apiKey) , m_status(SyncthingStatus::Disconnected) , m_keepPolling(false) + , m_abortingAllRequests(false) , m_abortingToReconnect(false) , m_requestCompletion(false) , m_lastEventId(0) @@ -254,6 +255,7 @@ void SyncthingConnection::disconnect() */ void SyncthingConnection::abortAllRequests() { + m_abortingAllRequests = true; if (m_configReply) { m_configReply->abort(); } @@ -287,6 +289,9 @@ void SyncthingConnection::abortAllRequests() for (auto *const reply : m_otherReplies) { reply->abort(); } + + m_abortingAllRequests = false; + handleAdditionalRequestCanceled(); } /*! diff --git a/connector/syncthingconnection.h b/connector/syncthingconnection.h index b14c764..f76cbae 100644 --- a/connector/syncthingconnection.h +++ b/connector/syncthingconnection.h @@ -321,6 +321,7 @@ private: QString m_password; SyncthingStatus m_status; bool m_keepPolling; + bool m_abortingAllRequests; bool m_abortingToReconnect; bool m_requestCompletion; int m_lastEventId; @@ -457,11 +458,12 @@ inline bool SyncthingConnection::isConnected() const * - Only requests which contribute to the overall state and population of myId(), dirInfo(), devInfo(), traffic * statistics, ... are considered. So requests for QR code, logs, clearing errors, rescan, ... are not taken * into account. + * - This function will also return true as long as the method abortAllRequests() is executed. */ inline bool SyncthingConnection::hasPendingRequests() const { - return m_configReply || m_statusReply || (m_eventsReply && !m_hasEvents) || (m_diskEventsReply && !m_hasDiskEvents) || m_connectionsReply - || m_dirStatsReply || m_devStatsReply || m_errorsReply || m_versionReply || !m_otherReplies.isEmpty(); + return m_abortingAllRequests || m_configReply || m_statusReply || (m_eventsReply && !m_hasEvents) || (m_diskEventsReply && !m_hasDiskEvents) + || m_connectionsReply || m_dirStatsReply || m_devStatsReply || m_errorsReply || m_versionReply || !m_otherReplies.isEmpty(); } /*!