//TODO: Why not replace with waypoint_buffer.clear() ? - because this will lead to memory leaks, the waypoint-structs have to be deleted, clear() would only delete the pointers.
// Why not replace with waypoint_buffer.clear() ?
// because this will lead to memory leaks, the waypoint-structs
// have to be deleted, clear() would only delete the pointers.
// Check if the correct number of bytes could be read
// First check initialization
if(startBytes.length()!=timeLen)
if(startTime==0)
{
{
ui->logStatsLabel->setText(tr("Error reading first %1 bytes").arg(timeLen));
QByteArraystartBytes=logFile.read(timeLen);
MainWindow::instance()->showCriticalMessage(tr("Failed loading MAVLink Logfile"),tr("Error reading first %1 bytes from logfile. Got %2 instead of %1 bytes. Is the logfile readable?").arg(timeLen).arg(startBytes.length()));
reset();
// Check if the correct number of bytes could be read
return;
if(startBytes.length()!=timeLen)
{
ui->logStatsLabel->setText(tr("Error reading first %1 bytes").arg(timeLen));
MainWindow::instance()->showCriticalMessage(tr("Failed loading MAVLink Logfile"),tr("Error reading first %1 bytes from logfile. Got %2 instead of %1 bytes. Is the logfile readable?").arg(timeLen).arg(startBytes.length()));
reset();
return;
}
// Convert data to timestamp
startTime=*((quint64*)(startBytes.constData()));
currentStartTime=QGC::groundTimeUsecs();
ok=true;
//qDebug() << "START TIME: " << startTime;
// Check if these bytes could be correctly decoded
if(!ok)
{
ui->logStatsLabel->setText(tr("Error decoding first timestamp, aborting."));
MainWindow::instance()->showCriticalMessage(tr("Failed loading MAVLink Logfile"),tr("Could not load initial timestamp from file %1. Is the file corrupted?").arg(logFile.fileName()));
reset();
return;
}
}
}
// Convert data to timestamp
startTime=*((quint64*)(startBytes.constData()));
currentStartTime=QGC::groundTimeUsecs();
ok=true;
//qDebug() << "START TIME: " << startTime;
// Initialization seems fine, load next chunk
QByteArraychunk=logFile.read(timeLen+packetLen);
QByteArraypacket=chunk.mid(0,packetLen);
// Check if these bytes could be correctly decoded
// Emit this packet
if(!ok)
emitbytesReady(logLink,packet);
// Check if reached end of file before reading next timestamp
ui->logStatsLabel->setText(tr("Error decoding first timestamp, aborting."));
// Reached end of file
MainWindow::instance()->showCriticalMessage(tr("Failed loading MAVLink Logfile"),tr("Could not load initial timestamp from file %1. Is the file corrupted?").arg(logFile.fileName()));
reset();
reset();
QStringstatus=tr("Reached end of MAVLink log file.");