[XPlane][FG] Q_UNREACHABLE removal follow up

* removed CSimulatorXPlane::connectionFromString as this only works for session DBus
* renamed to "checkConnectionViaSessionBus"
* discussed around here: https://discordapp.com/channels/539048679160676382/539925070550794240/668105458300485652
This commit is contained in:
Klaus Basan
2020-01-18 18:45:42 +01:00
parent 2ff46c5e11
commit 785dc7f016
5 changed files with 14 additions and 33 deletions

View File

@@ -319,7 +319,7 @@ namespace BlackSimPlugin
if (CDBusServer::isSessionOrSystemAddress(dbusAddress))
{
m_dBusConnection = connectionFromString(dbusAddress);
m_dBusConnection = QDBusConnection::sessionBus();
m_dbusMode = Session;
}
else if (CDBusServer::isQtDBusAddress(dbusAddress))
@@ -446,13 +446,6 @@ namespace BlackSimPlugin
return false;
}
QDBusConnection CSimulatorFlightgear::connectionFromString(const QString &str)
{
if (str == CDBusServer::sessionBusAddress()) { return QDBusConnection::sessionBus(); }
Q_UNREACHABLE();
return QDBusConnection("NO CONNECTION");
}
bool CSimulatorFlightgear::isPhysicallyRenderedAircraft(const CCallsign &callsign) const
{
return m_flightgearAircraftObjects.contains(callsign);
@@ -981,10 +974,10 @@ namespace BlackSimPlugin
if (this->isShuttingDown()) { return; }
Q_ASSERT_X(!CThreadUtils::isCurrentThreadApplicationThread(), Q_FUNC_INFO, "Expect to run in background");
QString dbusAddress = m_fgswiftbusServerSetting.getThreadLocal();
QString dbusAddress = m_fgSswiftBusServerSetting.getThreadLocal();
if (CDBusServer::isSessionOrSystemAddress(dbusAddress))
{
checkConnectionViaBus(dbusAddress);
checkConnectionViaSessionBus();
}
else if (CDBusServer::isQtDBusAddress(dbusAddress))
{
@@ -992,9 +985,9 @@ namespace BlackSimPlugin
}
}
void CSimulatorFlightgearListener::checkConnectionViaBus(const QString &address)
void CSimulatorFlightgearListener::checkConnectionViaSessionBus()
{
m_conn = CSimulatorFlightgear::connectionFromString(address);
m_conn = QDBusConnection::sessionBus();
if (!m_conn.isConnected())
{
m_conn.disconnectFromBus(m_conn.name());

View File

@@ -138,9 +138,6 @@ namespace BlackSimPlugin
virtual bool testSendSituationAndParts(const BlackMisc::Aviation::CCallsign &callsign, const BlackMisc::Aviation::CAircraftSituation &situation, const BlackMisc::Aviation::CAircraftParts &parts) override;
//! @}
//! Creates an appropriate dbus connection from the string describing it
static QDBusConnection connectionFromString(const QString &str);
protected:
//! \name ISimulator implementations
//! @{
@@ -264,7 +261,7 @@ namespace BlackSimPlugin
private:
void checkConnection();
void checkConnectionViaBus(const QString &address);
void checkConnectionViaSessionBus();
void checkConnectionViaPeer(const QString &address);
void checkConnectionCommon();
@@ -273,7 +270,7 @@ namespace BlackSimPlugin
QTimer m_timer { this };
QDBusConnection m_conn { "default" };
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TFGSwiftBusServer> m_fgswiftbusServerSetting { this, &CSimulatorFlightgearListener::fgSwiftBusServerSettingChanged };
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TFGSwiftBusServer> m_fgSswiftBusServerSetting { this, &CSimulatorFlightgearListener::fgSwiftBusServerSettingChanged };
};
//! Factory for creating CSimulatorFlightgear instance