mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 08:36:52 +08:00
Connection guard (detected during #477)
Disconnects Qt signal/slot conenction when destroyed
This commit is contained in:
committed by
Mathew Sutcliffe
parent
3acf085b92
commit
23856bbc57
@@ -21,7 +21,7 @@ namespace BlackMisc
|
||||
{
|
||||
CWebDataServicesAware::~CWebDataServicesAware()
|
||||
{
|
||||
disconnectSignals();
|
||||
this->m_swiftConnections.disconnectAll();
|
||||
}
|
||||
|
||||
CServerList CWebDataServicesAware::getVatsimFsdServers() const
|
||||
@@ -264,7 +264,7 @@ namespace BlackMisc
|
||||
void CWebDataServicesAware::setProvider(IWebDataServicesProvider *webDataReaderProvider)
|
||||
{
|
||||
Q_ASSERT_X(webDataReaderProvider, Q_FUNC_INFO, "missing provider");
|
||||
disconnectSignals();
|
||||
this->m_swiftConnections.disconnectAll();
|
||||
m_webDataReaderProvider = webDataReaderProvider;
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ namespace BlackMisc
|
||||
|
||||
void CWebDataServicesAware::gracefulShutdown()
|
||||
{
|
||||
disconnectSignals();
|
||||
this->m_swiftConnections.disconnectAll();
|
||||
this->m_webDataReaderProvider = nullptr;
|
||||
}
|
||||
|
||||
@@ -317,13 +317,5 @@ namespace BlackMisc
|
||||
return this->m_webDataReaderProvider->readDbDataFromDisk(dir, inBackround);
|
||||
}
|
||||
|
||||
void CWebDataServicesAware::disconnectSignals()
|
||||
{
|
||||
for (QMetaObject::Connection &c : m_swiftConnections)
|
||||
{
|
||||
QObject::disconnect(c);
|
||||
}
|
||||
m_swiftConnections.clear();
|
||||
}
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "blackmisc/simulation/simulatedaircraft.h"
|
||||
#include "blackmisc/weather/metarset.h"
|
||||
#include "blackmisc/countrylist.h"
|
||||
#include "blackmisc/connectionguard.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
@@ -343,8 +344,8 @@ namespace BlackMisc
|
||||
CWebDataServicesAware(IWebDataServicesProvider *webDataReaderProvider = nullptr) : m_webDataReaderProvider(webDataReaderProvider) { }
|
||||
|
||||
private:
|
||||
IWebDataServicesProvider *m_webDataReaderProvider = nullptr; //!< access to object
|
||||
QList<QMetaObject::Connection> m_swiftConnections; //!< signal connection with swift
|
||||
IWebDataServicesProvider *m_webDataReaderProvider = nullptr; //!< access to object
|
||||
BlackMisc::CConnectionGuard m_swiftConnections; //!< signal connection with swift
|
||||
|
||||
//! Disconnect all signals
|
||||
void disconnectSignals();
|
||||
|
||||
Reference in New Issue
Block a user