Commit c7ff431e authored by Basil Huber's avatar Basil Huber

Repaired overwriting current files for flight data log (fix #1241)

changed QGCApplication::saveTempFlightDataLogOnMainThread(QString tempLogfile) to enable overwriting files
existing file is removed before saving file (QFile::copy cannot overwrite files)
parent 47c0d51f
...@@ -483,15 +483,28 @@ void QGCApplication::criticalMessageBoxOnMainThread(const QString& title, const ...@@ -483,15 +483,28 @@ void QGCApplication::criticalMessageBoxOnMainThread(const QString& title, const
void QGCApplication::saveTempFlightDataLogOnMainThread(QString tempLogfile) void QGCApplication::saveTempFlightDataLogOnMainThread(QString tempLogfile)
{ {
QString saveFilename = QGCFileDialog::getSaveFileName( bool saveError;
MainWindow::instance(), do{
tr("Save Flight Data Log"), saveError = false;
qgcApp()->mavlinkLogFilesLocation(), QString saveFilename = QGCFileDialog::getSaveFileName(
tr("Flight Data Log Files (*.mavlink)"), MainWindow::instance(),
"mavlink"); tr("Save Flight Data Log"),
if (!saveFilename.isEmpty()) { qgcApp()->mavlinkLogFilesLocation(),
QFile::copy(tempLogfile, saveFilename); tr("Flight Data Log Files (*.mavlink)"),
} "mavlink");
if (!saveFilename.isEmpty()) {
// if file exsits already, try to remove it first to overwrite it
if(QFile::exists(saveFilename) && !QFile::remove(saveFilename)){
saveError = true;
QMessageBox::warning (MainWindow::instance(), "File Error","Could not overwrite existing file");
QFile::copy(tempLogfile, saveFilename);
} else if(!QFile::copy(tempLogfile, saveFilename)) {
saveError = true;
QMessageBox::warning (MainWindow::instance(), "File Error","Could not create file");
}
}
} while(saveError); // if the file could not be overwritten, ask for new file
QFile::remove(tempLogfile); QFile::remove(tempLogfile);
} }
......
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