Commit b1a9d302 authored by Don Gagne's avatar Don Gagne

Merge pull request #1242 from basil-huber/Fix1241

Repaired overwriting current files for flight data log (fix #1241)
parents 64e8919c 9134bd06
......@@ -490,15 +490,29 @@ void QGCApplication::criticalMessageBoxOnMainThread(const QString& title, const
void QGCApplication::saveTempFlightDataLogOnMainThread(QString tempLogfile)
{
QString saveFilename = QGCFileDialog::getSaveFileName(
MainWindow::instance(),
tr("Save Flight Data Log"),
qgcApp()->mavlinkLogFilesLocation(),
tr("Flight Data Log Files (*.mavlink)"),
"mavlink");
if (!saveFilename.isEmpty()) {
QFile::copy(tempLogfile, saveFilename);
}
bool saveError;
do{
saveError = false;
QString saveFilename = QGCFileDialog::getSaveFileName(
MainWindow::instance(),
tr("Save Flight Data Log"),
qgcApp()->mavlinkLogFilesLocation(),
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)){
// if the file cannot be removed, prompt user and ask new path
saveError = true;
QGCMessageBox::warning("File Error","Could not overwrite existing file.\nPlease provide a different file name to save to.");
} else if(!QFile::copy(tempLogfile, saveFilename)) {
// if file could not be copied, prompt user and ask new path
saveError = true;
QGCMessageBox::warning("File Error","Could not create file.\nPlease provide a different file name to save to.");
}
}
} while(saveError); // if the file could not be overwritten, ask for new file
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