Commit 5ddd7d6a authored by Nate Weibley's avatar Nate Weibley

Fix thread unsafe simulator shutdown. Use a signal/slot connection to execute on correct thread

parent c4f83d17
......@@ -70,6 +70,7 @@ QGCFlightGearLink::QGCFlightGearLink(UASInterface* mav, QString startupArguments
// We need a mechanism so show error message from our FGLink thread on the UI thread. This signal connection will do that for us.
connect(this, &QGCFlightGearLink::showCriticalMessageFromThread, qgcApp(), &QGCApplication::criticalMessageBoxOnMainThread);
connect(this, &QGCFlightGearLink::disconnectSim, this, &QGCFlightGearLink::disconnectSimulation);
}
QGCFlightGearLink::~QGCFlightGearLink()
......@@ -496,13 +497,13 @@ bool QGCFlightGearLink::disconnectSimulation()
if (_fgProcess)
{
_fgProcess->close();
delete _fgProcess;
_fgProcess->deleteLater();
_fgProcess = NULL;
}
if (_udpCommSocket)
{
_udpCommSocket->close();
delete _udpCommSocket;
_udpCommSocket->deleteLater();
_udpCommSocket = NULL;
}
......
......@@ -83,6 +83,11 @@ signals:
**/
void simulationDisconnected();
/**
* @brief Thread safe signal to disconnect simulator from other threads
**/
void disconnectSim();
/**
* @brief This signal is emitted instantly when the link status changes
**/
......
......@@ -3227,7 +3227,7 @@ void UAS::startHil()
void UAS::stopHil()
{
if (simulation && simulation->isConnected()) {
simulation->disconnectSimulation();
simulation->disconnectSim();
setMode(base_mode & ~MAV_MODE_FLAG_HIL_ENABLED, custom_mode);
qDebug() << __FILE__ << __LINE__ << "HIL is onboard not enabled, trying to disable.";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment