diff --git a/src/uas/UAS.cc b/src/uas/UAS.cc index f26acea..9bc6ca3 100644 --- a/src/uas/UAS.cc +++ b/src/uas/UAS.cc @@ -1387,7 +1387,7 @@ void UAS::receiveMessage(LinkInterface* link, mavlink_message_t message) ++imagePacketsArrived; // emit signal if all packets arrived - if ((imagePacketsArrived >= imagePackets)) + if (imagePacketsArrived >= imagePackets) { // Restart statemachine imagePackets = 0; @@ -2202,13 +2202,15 @@ QImage UAS::getImage() if (!image.loadFromData(imageRecBuffer)) { qDebug() << __FILE__ << __LINE__ << "Loading data from image buffer failed!"; + return QImage(); } } + // Restart statemachine imagePacketsArrived = 0; - //imageRecBuffer.clear(); + imagePackets = 0; + imageRecBuffer.clear(); return image; - } void UAS::requestImage() diff --git a/src/ui/HUD.cc b/src/ui/HUD.cc index 2c13dc5..48a74c0 100644 --- a/src/ui/HUD.cc +++ b/src/ui/HUD.cc @@ -119,7 +119,7 @@ HUD::HUD(int width, int height, QWidget* parent) { Q_UNUSED(width); Q_UNUSED(height); - + // Set auto fill to false setAutoFillBackground(false); @@ -1374,7 +1374,10 @@ void HUD::copyImage(UASInterface* uas) UAS* u = qobject_cast(uas); if (u) { - this->glImage = u->getImage(); + QImage temp_im = u->getImage(); + if (temp_im.byteCount() > 0) { + this->glImage = temp_im; + } // Save to directory if logging is enabled if (imageLoggingEnabled)