mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 06:35:52 +08:00
Check if SimConnect was properly loaded before attempting to use it
This commit adds a check that loadAndResolveSimConnect actually succeeds and moves it right before SimConnect_Open is called. The method itself was improved to check whether symbols got loaded already in a previous run, before doing everything again.
This commit is contained in:
committed by
Klaus Basan
parent
f3024d15cb
commit
ce99c0535f
@@ -87,6 +87,9 @@ namespace BlackSimPlugin
|
||||
{
|
||||
if (this->isConnected()) { return true; }
|
||||
this->reset();
|
||||
|
||||
if (!loadAndResolveSimConnect(true)) { return false; }
|
||||
|
||||
if (FAILED(SimConnect_Open(&m_hSimConnect, sApp->swiftVersionChar(), nullptr, 0, 0, 0)))
|
||||
{
|
||||
// reset state as expected for unconnected
|
||||
@@ -2017,7 +2020,6 @@ namespace BlackSimPlugin
|
||||
constexpr int QueryInterval = 5 * 1000; // 5 seconds
|
||||
m_timer.setInterval(QueryInterval);
|
||||
m_timer.setObjectName(this->objectName().append(":m_timer"));
|
||||
loadAndResolveSimConnect(true);
|
||||
connect(&m_timer, &QTimer::timeout, this, &CSimulatorFsxCommonListener::checkConnection);
|
||||
}
|
||||
|
||||
@@ -2027,6 +2029,9 @@ namespace BlackSimPlugin
|
||||
m_simConnectVersion.clear();
|
||||
m_simulatorName.clear();
|
||||
m_simulatorDetails.clear();
|
||||
|
||||
if (!loadAndResolveSimConnect(true)) { return; }
|
||||
|
||||
m_timer.start();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user