Browse Source

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

QGC4.4
Nate Weibley 10 years ago
parent
commit
5ddd7d6adb
  1. 5
      src/comm/QGCFlightGearLink.cc
  2. 5
      src/comm/QGCHilLink.h
  3. 2
      src/uas/UAS.cc

5
src/comm/QGCFlightGearLink.cc

@ -70,6 +70,7 @@ QGCFlightGearLink::QGCFlightGearLink(UASInterface* mav, QString startupArguments @@ -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() @@ -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;
}

5
src/comm/QGCHilLink.h

@ -84,6 +84,11 @@ signals: @@ -84,6 +84,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
**/
void simulationConnected(bool connected);

2
src/uas/UAS.cc

@ -3227,7 +3227,7 @@ void UAS::startHil() @@ -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.";
}

Loading…
Cancel
Save