Delete QDBusServiceWatcher when unloading X-Plane driver.

Summary:
When unloading a sim driver, first its threads are killed, then the driver object is destroyed.

This means that when the `QDBusServiceWatcher` child object is destroyed, it deadlocks waiting for a thread that was already killed (T147).

This change causes the `QDBusServiceWatcher` to be deleted before the driver is unloaded.

Reviewers: #swift_pilot_client, kbasan, rwinklmeier

Reviewed By: #swift_pilot_client, kbasan, rwinklmeier

Subscribers: kbasan, jenkins

Tags: #swift_pilot_client

Differential Revision: https://dev.swift-project.org/D50
This commit is contained in:
Mathew Sutcliffe
2017-09-08 17:49:00 +01:00
parent e2b00f1f9b
commit f1211d328e
2 changed files with 12 additions and 4 deletions

View File

@@ -113,6 +113,13 @@ namespace BlackSimPlugin
resetData();
}
void CSimulatorXPlane::unload()
{
CSimulatorCommon::unload();
delete m_watcher;
m_watcher = nullptr;
}
// convert xplane squawk mode to swift squawk mode
BlackMisc::Aviation::CTransponder::TransponderMode xpdrMode(int xplaneMode, bool ident)
{
@@ -255,7 +262,7 @@ namespace BlackSimPlugin
connect(m_traffic, &CXSwiftBusTrafficProxy::installedModelsUpdated, this, &CSimulatorXPlane::ps_installedModelsUpdated);
m_service->updateAirportsInRange();
m_traffic->updateInstalledModels();
m_watcher->setConnection(m_conn);
if (m_watcher) { m_watcher->setConnection(m_conn); }
loadCslPackages();
emitSimulatorCombinedStatus();
return true;
@@ -276,7 +283,7 @@ namespace BlackSimPlugin
}
m_conn = QDBusConnection { "default" };
m_watcher->setConnection(m_conn);
if (m_watcher) { m_watcher->setConnection(m_conn); }
delete m_service;
delete m_traffic;
delete m_weather;
@@ -290,7 +297,7 @@ namespace BlackSimPlugin
void CSimulatorXPlane::ps_serviceUnregistered()
{
m_conn = QDBusConnection { "default" };
m_watcher->setConnection(m_conn);
if (m_watcher) { m_watcher->setConnection(m_conn); }
delete m_service;
delete m_traffic;
delete m_weather;
@@ -746,7 +753,7 @@ namespace BlackSimPlugin
{
if (m_watcher)
{
m_watcher->deleteLater();
delete m_watcher;
m_watcher = nullptr;
}
}

View File

@@ -100,6 +100,7 @@ namespace BlackSimPlugin
virtual bool setTimeSynchronization(bool enable, const BlackMisc::PhysicalQuantities::CTime &offset) override;
virtual BlackMisc::PhysicalQuantities::CTime getTimeSynchronizationOffset() const override { return BlackMisc::PhysicalQuantities::CTime(0, BlackMisc::PhysicalQuantities::CTimeUnit::hrmin()); }
virtual bool setInterpolatorMode(BlackMisc::Simulation::CInterpolatorMulti::Mode mode, const BlackMisc::Aviation::CCallsign &callsign) override;
virtual void unload() override;
//! @}
//! Creates an appropriate dbus connection from the string describing it