mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-01 05:26:45 +08:00
Prevent inserting default-constructed elements in CSimulatorFsxCommon::m_simConnectObjects.
Hopefully this fixes null pointer dereference of CSimConnectObject::m_interpolator.
This commit is contained in:
@@ -31,11 +31,13 @@ namespace BlackSimPlugin
|
||||
|
||||
void CSimConnectObject::addAircraftParts(const CAircraftParts &parts)
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
m_interpolator->addAircraftParts(parts);
|
||||
}
|
||||
|
||||
void CSimConnectObject::addAircraftSituation(const CAircraftSituation &situation)
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
m_interpolator->addAircraftSituation(situation);
|
||||
}
|
||||
|
||||
@@ -76,11 +78,13 @@ namespace BlackSimPlugin
|
||||
|
||||
void CSimConnectObject::toggleInterpolatorMode()
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
this->m_interpolator->toggleMode();
|
||||
}
|
||||
|
||||
bool CSimConnectObject::setInterpolatorMode(CInterpolatorMulti::Mode mode)
|
||||
{
|
||||
Q_ASSERT(m_interpolator);
|
||||
return this->m_interpolator->setMode(mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -1072,7 +1072,7 @@ namespace BlackSimPlugin
|
||||
objectId, SIMCONNECT_DATA_SET_FLAG_DEFAULT, 0,
|
||||
sizeof(DataDefinitionRemoteAircraftPartsWithoutLights), &ddRemoteAircraftPartsWithoutLights);
|
||||
|
||||
if (hr == S_OK)
|
||||
if (hr == S_OK && m_simConnectObjects.contains(simObj.getCallsign()))
|
||||
{
|
||||
// Update data
|
||||
CSimConnectObject &objUdpate = m_simConnectObjects[simObj.getCallsign()];
|
||||
@@ -1103,8 +1103,11 @@ namespace BlackSimPlugin
|
||||
const CCallsign callsign(simObj.getCallsign());
|
||||
|
||||
// Update data
|
||||
CSimConnectObject &simObjToUpdate = m_simConnectObjects[callsign];
|
||||
simObjToUpdate.setLightsAsSent(lightsWanted);
|
||||
if (m_simConnectObjects.contains(callsign))
|
||||
{
|
||||
CSimConnectObject &simObjToUpdate = m_simConnectObjects[callsign];
|
||||
simObjToUpdate.setLightsAsSent(lightsWanted);
|
||||
}
|
||||
|
||||
// state available, then I can toggle
|
||||
if (!lightsIsState.isNull())
|
||||
@@ -1141,6 +1144,7 @@ namespace BlackSimPlugin
|
||||
CLogMessage(this).info("Missing light state for '%1'") << callsign;
|
||||
QTimer::singleShot(2500, this, [ = ]
|
||||
{
|
||||
if (!m_simConnectObjects.contains(callsign)) { return; }
|
||||
const CSimConnectObject currentSimObj = m_simConnectObjects[callsign];
|
||||
if (!currentSimObj.hasValidRequestAndObjectId()) { return; } // stale
|
||||
if (lightsWanted != currentSimObj.getLightsAsSent()) { return; } // changed in between
|
||||
@@ -1229,7 +1233,8 @@ namespace BlackSimPlugin
|
||||
m_hSimConnect, simObject.getRequestId() + RequestSimDataOffset,
|
||||
CSimConnectDefinitions::DataRemoteAircraftSimData,
|
||||
simObject.getObjectId(), period);
|
||||
if (result == S_OK)
|
||||
|
||||
if (result == S_OK && m_simConnectObjects.contains(simObject.getCallsign()))
|
||||
{
|
||||
m_simConnectObjects[simObject.getCallsign()].setSimDataPeriod(period);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user