mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Handling during shuttdown
* Do not start new event loop when shutting down * FSX Listener end checking when shutting down * in same step fixed: FSX driver can connect to P3D and FSX but not vice versa
This commit is contained in:
committed by
Mathew Sutcliffe
parent
b3186d6b91
commit
380da41544
@@ -626,9 +626,9 @@ namespace BlackCore
|
||||
|
||||
bool CApplication::isNetworkAccessible() const
|
||||
{
|
||||
if (!this->m_accessManager) return false;
|
||||
if (!this->m_accessManager) { return false; }
|
||||
const QNetworkAccessManager::NetworkAccessibility a = this->m_accessManager->networkAccessible();
|
||||
if (a == QNetworkAccessManager::Accessible) return true;
|
||||
if (a == QNetworkAccessManager::Accessible) { return true; }
|
||||
|
||||
// currently I also accept unknown
|
||||
return a == QNetworkAccessManager::UnknownAccessibility;
|
||||
@@ -658,6 +658,7 @@ namespace BlackCore
|
||||
{
|
||||
instance()->gracefulShutdown();
|
||||
}
|
||||
|
||||
// when the event loop is not running, this does nothing
|
||||
QCoreApplication::exit(retcode);
|
||||
}
|
||||
@@ -669,6 +670,7 @@ namespace BlackCore
|
||||
|
||||
void CApplication::processEventsFor(int milliseconds)
|
||||
{
|
||||
if (CApplication::instance()->isShuttingDown()) { return; }
|
||||
QEventLoop eventLoop;
|
||||
QTimer::singleShot(milliseconds, &eventLoop, &QEventLoop::quit);
|
||||
eventLoop.exec();
|
||||
|
||||
@@ -1503,13 +1503,13 @@ namespace BlackSimPlugin
|
||||
bool check = false;
|
||||
if (result == S_OK)
|
||||
{
|
||||
for (int i = 0; !check && i < 3; i++)
|
||||
for (int i = 0; !check && i < 3 && !this->isShuttingDown(); i++)
|
||||
{
|
||||
// result not always in first dispatch
|
||||
// result not always in first dispatch as we first have to obtain simulator name
|
||||
result = SimConnect_CallDispatch(hSimConnect, CSimulatorFsxCommonListener::SimConnectProc, this);
|
||||
if (result != S_OK) { break; } // means serious failure
|
||||
check = this->checkVersionAndSimulator();
|
||||
sApp->processEventsFor(500);
|
||||
if (!check) { sApp->processEventsFor(500); }
|
||||
}
|
||||
}
|
||||
SimConnect_Close(hSimConnect);
|
||||
@@ -1522,17 +1522,20 @@ namespace BlackSimPlugin
|
||||
|
||||
bool CSimulatorFsxCommonListener::checkVersionAndSimulator() const
|
||||
{
|
||||
const CSimulatorInfo sim(getPluginInfo().getIdentifier());
|
||||
const QString simName = m_simulatorName.toLower().trimmed();
|
||||
const CSimulatorInfo pluginSim(getPluginInfo().getIdentifier());
|
||||
const QString connectedSimName = m_simulatorName.toLower().trimmed();
|
||||
|
||||
if (simName.isEmpty()) { return false; }
|
||||
if (sim.p3d())
|
||||
if (connectedSimName.isEmpty()) { return false; }
|
||||
if (pluginSim.p3d())
|
||||
{
|
||||
return simName.contains("lockheed") || simName.contains("martin") || simName.contains("p3d") || simName.contains("prepar");
|
||||
// P3D drivers only work with P3D
|
||||
return connectedSimName.contains("lockheed") || connectedSimName.contains("martin") || connectedSimName.contains("p3d") || connectedSimName.contains("prepar");
|
||||
}
|
||||
else if (sim.fsx())
|
||||
else if (pluginSim.fsx())
|
||||
{
|
||||
return simName.contains("fsx") || simName.contains("microsoft") || simName.contains("simulator x");
|
||||
// FSX drivers works with P3D and FSX
|
||||
return connectedSimName.contains("fsx") || connectedSimName.contains("microsoft") || connectedSimName.contains("simulator x") ||
|
||||
connectedSimName.contains("lockheed") || connectedSimName.contains("martin") || connectedSimName.contains("p3d") || connectedSimName.contains("prepar");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user