refs #935, avoid issues when shutting down

This commit is contained in:
Klaus Basan
2017-04-13 01:06:05 +02:00
committed by Mathew Sutcliffe
parent d475246941
commit f34e80ea62
5 changed files with 20 additions and 2 deletions

View File

@@ -8,6 +8,7 @@
*/
#include "blackcore/simulator.h"
#include "blackcore/application.h"
#include <QFlag>
#include <Qt>
@@ -83,6 +84,11 @@ namespace BlackCore
return m_info.toQString();
}
bool ISimulatorListener::isShuttingDown() const
{
return (!sApp || sApp->isShuttingDown());
}
void ISimulatorListener::start()
{
if (m_isRunning) { return; }
@@ -92,7 +98,7 @@ namespace BlackCore
void ISimulatorListener::stop()
{
if(!m_isRunning) { return; }
if (!m_isRunning) { return; }
stopImpl();
m_isRunning = false;
}

View File

@@ -151,6 +151,9 @@ namespace BlackCore
//! Driver will be unloaded
virtual void unload() = 0;
//! Is overall (swift) application shutting down
virtual bool isShuttingDown() const = 0;
//! Set interpolation mode, empty callsign applies to all know callsigns
virtual bool setInterpolatorMode(BlackMisc::Simulation::CInterpolatorMulti::Mode mode, const BlackMisc::Aviation::CCallsign &callsign) = 0;
@@ -253,6 +256,9 @@ namespace BlackCore
//! Info about the backend system (if available)
virtual QString backendInfo() const;
//! Overall (swift) application shutting down
virtual bool isShuttingDown() const;
public slots:
//! Start listening for the simulator to start.
void start();

View File

@@ -291,6 +291,11 @@ namespace BlackCore
this->m_remoteAircraftProviderConnections.disconnectAll(); // disconnect signals from provider
}
bool CSimulatorCommon::isShuttingDown() const
{
return (!sApp || sApp->isShuttingDown());
}
void CSimulatorCommon::setInterpolationAndRenderingSetup(const CInterpolationAndRenderingSetup &setup)
{
{

View File

@@ -83,6 +83,7 @@ namespace BlackCore
virtual BlackMisc::Aviation::CAirportList getAirportsInRange() const override;
virtual void setWeatherActivated(bool activated) override;
virtual void unload() override;
virtual bool isShuttingDown() const override;
virtual int physicallyRemoveMultipleRemoteAircraft(const BlackMisc::Aviation::CCallsignSet &callsigns) override;
//! \addtogroup swiftdotcommands

View File

@@ -1356,7 +1356,7 @@ namespace BlackSimPlugin
void CSimulatorFsxCommonListener::checkConnection()
{
Q_ASSERT_X(sApp, Q_FUNC_INFO, "Missing sApp");
if (this->isShuttingDown()) { return; }
Q_ASSERT_X(!CThreadUtils::isCurrentThreadApplicationThread(), Q_FUNC_INFO, "Expect to run in background");
HANDLE hSimConnect;
HRESULT result = SimConnect_Open(&hSimConnect, sApp->swiftVersionChar(), nullptr, 0, 0, 0);