Commit 1683185c authored by Gus Grubba's avatar Gus Grubba Committed by Gus Grubba

CP - Fix crash bug that could occur when reconnecting a camera.

parent cf7e6107
......@@ -12,8 +12,9 @@
QGC_LOGGING_CATEGORY(CameraManagerLog, "CameraManagerLog")
//-----------------------------------------------------------------------------
QGCCameraManager::CameraStruct::CameraStruct(QObject* parent)
QGCCameraManager::CameraStruct::CameraStruct(QObject* parent, uint8_t compID_)
: QObject(parent)
, compID(compID_)
{
}
......@@ -112,7 +113,7 @@ QGCCameraManager::_handleHeartbeat(const mavlink_message_t &message)
QString sCompID = QString::number(message.compid);
if(!_cameraInfoRequest.contains(sCompID)) {
qCDebug(CameraManagerLog) << "Hearbeat from " << message.compid;
CameraStruct* pInfo = new CameraStruct(this);
CameraStruct* pInfo = new CameraStruct(this, message.compid);
pInfo->lastHeartbeat.start();
_cameraInfoRequest[sCompID] = pInfo;
//-- Request camera info
......@@ -226,7 +227,9 @@ QGCCameraManager::_cameraTimeout()
//-- Has the camera stopped talking to us?
if(pInfo->lastHeartbeat.elapsed() > 5000) {
//-- Camera is gone. Remove it.
bool autoStream = false;
QGCCameraControl* pCamera = _findCamera(pInfo->compID);
if(pCamera) {
qWarning() << "Camera" << pCamera->modelName() << "stopped transmitting. Removing from list.";
int idx = _cameraLabels.indexOf(pCamera->modelName());
if(idx >= 0) {
......@@ -236,9 +239,10 @@ QGCCameraManager::_cameraTimeout()
if(idx >= 0) {
_cameras.removeAt(idx);
}
bool autoStream = pCamera->autoStream();
autoStream = pCamera->autoStream();
pCamera->deleteLater();
delete pInfo;
}
_cameraInfoRequest.remove(sCompID);
emit cameraLabelsChanged();
//-- If we have another camera, switch current camera.
......
......@@ -76,7 +76,7 @@ protected:
class CameraStruct : public QObject {
public:
CameraStruct(QObject* parent);
CameraStruct(QObject* parent, uint8_t compID_);
QTime lastHeartbeat;
bool infoReceived = false;
bool gaveUp = false;
......
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