From 1018d06f70088ed64e7273677bae0c70d00e1945 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 2 Nov 2017 20:06:10 +0100 Subject: [PATCH] Ref T180, do not disconnect from dispatch (SimConnectProc) function This causes a crash in P3Dv4 and has been wrong all the time because it closes itself from within the dispatcher --- src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp index c4157879f..1b7c70bf8 100644 --- a/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp +++ b/src/plugins/simulator/fsxcommon/simulatorfsxcommon.cpp @@ -342,7 +342,10 @@ namespace BlackSimPlugin { // reset complete state, we are going down m_simulatingChangedTs = QDateTime::currentMSecsSinceEpoch(); - disconnectFrom(); + if (m_simConnectTimerId >= 0) { killTimer(m_simConnectTimerId); } + + // if called from dispatch function, avoid that SimConnectProc disconnects itself while in SimConnectProc + QTimer::singleShot(0, this, &CSimulatorFsxCommon::disconnectFrom); } DWORD CSimulatorFsxCommon::obtainRequestIdSimData() @@ -761,11 +764,12 @@ namespace BlackSimPlugin { // 2nd time, an error / avoid multiple messages // idea: if it happens once ignore - CLogMessage(this).error("FSX: Dispatch error"); + CLogMessage(this).error("FSX/P3D: Dispatch error"); } else if (m_dispatchErrors > 5) { // this normally happens during a FSX crash or shutdown + CLogMessage(this).error("FSX/P3D: Multiple dispatch errors, disconnecting"); this->disconnectFrom(); } return;