mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
Ref T312, added checkImpl/check in simulator listeners
This commit is contained in:
@@ -1096,11 +1096,11 @@ namespace BlackSimPlugin
|
||||
{
|
||||
QString dbusAddress = m_xswiftbusServerSetting.getThreadLocal();
|
||||
|
||||
if (BlackMisc::CDBusServer::isSessionOrSystemAddress(dbusAddress))
|
||||
if (CDBusServer::isSessionOrSystemAddress(dbusAddress))
|
||||
{
|
||||
checkConnectionViaBus(dbusAddress);
|
||||
}
|
||||
else if (BlackMisc::CDBusServer::isQtDBusAddress(dbusAddress))
|
||||
else if (CDBusServer::isQtDBusAddress(dbusAddress))
|
||||
{
|
||||
m_timer.start();
|
||||
}
|
||||
@@ -1121,6 +1121,20 @@ namespace BlackSimPlugin
|
||||
m_timer.stop();
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneListener::checkImpl()
|
||||
{
|
||||
if (!m_timer.isActive()) { return; }
|
||||
if (this->isShuttingDown()) { return; }
|
||||
|
||||
m_timer.start(); // restart because we will check just now
|
||||
QPointer<CSimulatorXPlaneListener> myself(this);
|
||||
QTimer::singleShot(0, this, [ = ]
|
||||
{
|
||||
if (!myself) { return; }
|
||||
this->checkConnectionViaPeer();
|
||||
});
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneListener::checkConnectionViaBus(const QString &address)
|
||||
{
|
||||
if (m_watcher) { return; }
|
||||
@@ -1148,7 +1162,7 @@ namespace BlackSimPlugin
|
||||
void CSimulatorXPlaneListener::checkConnectionViaPeer()
|
||||
{
|
||||
m_conn = QDBusConnection::connectToPeer(m_xswiftbusServerSetting.getThreadLocal(), "xswiftbus");
|
||||
if (! m_conn.isConnected())
|
||||
if (!m_conn.isConnected())
|
||||
{
|
||||
// This is required to cleanup the connection in QtDBus
|
||||
m_conn.disconnectFromPeer(m_conn.name());
|
||||
|
||||
@@ -118,7 +118,7 @@ namespace BlackSimPlugin
|
||||
QObject *parent = nullptr);
|
||||
|
||||
//! Dtor
|
||||
virtual ~CSimulatorXPlane();
|
||||
virtual ~CSimulatorXPlane() override;
|
||||
|
||||
//! \name ISimulator implementations
|
||||
//! @{
|
||||
@@ -273,6 +273,9 @@ namespace BlackSimPlugin
|
||||
//! \copydoc BlackCore::ISimulatorListener::stopImpl
|
||||
virtual void stopImpl() override;
|
||||
|
||||
//! \copydoc BlackCore::ISimulatorListener::checkImpl
|
||||
virtual void checkImpl() override;
|
||||
|
||||
private:
|
||||
//! Check if XSwiftBus service is already registered on the bus
|
||||
void checkConnectionViaBus(const QString &address);
|
||||
|
||||
Reference in New Issue
Block a user