From 5b8d76c06c2d53feb13b34e2939e6c66ddb511d5 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Mon, 15 May 2017 21:59:48 +0100 Subject: [PATCH] Always disconnect CNetworkVatlib when shutting down. --- src/blackcore/context/contextnetworkimpl.cpp | 6 +----- src/blackcore/vatsim/networkvatlib.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/blackcore/context/contextnetworkimpl.cpp b/src/blackcore/context/contextnetworkimpl.cpp index 388b11b5b..9cc5471d3 100644 --- a/src/blackcore/context/contextnetworkimpl.cpp +++ b/src/blackcore/context/contextnetworkimpl.cpp @@ -216,16 +216,12 @@ namespace BlackCore CStatusMessage CContextNetwork::disconnectFromNetwork() { if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } - if (this->m_network->isConnected()) + if (this->m_network->isConnected() || this->m_network->isPendingConnection()) { this->m_currentStatus = INetwork::Disconnecting; // as semaphore we are going to disconnect this->m_network->terminateConnection(); return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityInfo, "Connection terminating"); } - else if (this->isPendingConnection()) - { - return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityInfo, "Pending connection, please wait"); - } else { return CStatusMessage({ CLogCategory::validation() }, CStatusMessage::SeverityWarning, "Already disconnected"); diff --git a/src/blackcore/vatsim/networkvatlib.cpp b/src/blackcore/vatsim/networkvatlib.cpp index 72c04a239..ae23195a0 100644 --- a/src/blackcore/vatsim/networkvatlib.cpp +++ b/src/blackcore/vatsim/networkvatlib.cpp @@ -39,6 +39,7 @@ #include "blackmisc/logmessage.h" #include "blackmisc/logcategory.h" #include "blackmisc/statusmessage.h" +#include "blackmisc/verify.h" #include "vatlib/vatlib.h" #include @@ -157,7 +158,8 @@ namespace BlackCore CNetworkVatlib::~CNetworkVatlib() { - Q_ASSERT_X(isDisconnected(), Q_FUNC_INFO, "CNetworkVatlib destroyed while still connected."); + BLACK_VERIFY_X(isDisconnected(), Q_FUNC_INFO, "CNetworkVatlib destroyed while still connected."); + terminateConnection(); } void CNetworkVatlib::process() @@ -466,7 +468,7 @@ namespace BlackCore void CNetworkVatlib::terminateConnection() { stopPositionTimers(); - if (m_net && isConnected()) + if (m_net && !isDisconnected()) { // Process all pending tasks before logging off process();