Re #1567: readEeprom():

* added PID to temporary file name
 * better error message
 * temporary file deletion
This commit is contained in:
Damjan Adamic
2014-08-03 17:38:24 +02:00
parent 12ba27247e
commit 55cb5dce87
2 changed files with 12 additions and 6 deletions
+2 -2
View File
@@ -156,11 +156,11 @@ void avrOutputDialog::doCopy()
dest.close(); dest.close();
} }
else { else {
QMessageBox::warning(this, tr("Error"),tr("Cannot write destination") + ": " + dest.errorString()); QMessageBox::warning(this, tr("Error"),tr("Cannot write destination") + ": " + dest.fileName() + ", " + tr("reason") + ": " + dest.errorString());
} }
} }
else { else {
QMessageBox::warning(this, tr("Error"),tr("Cannot open source file") + ": " + source.errorString()); QMessageBox::warning(this, tr("Error"),tr("Cannot open source file") + ": " + source.fileName() + ", " + tr("reason") + ": " + source.errorString());
} }
source.close(); source.close();
+10 -4
View File
@@ -947,20 +947,23 @@ QString MainWindow::FindMassstoragePath(QString filename)
void MainWindow::readEeprom() void MainWindow::readEeprom()
{ {
QString tempDir = QDir::tempPath(); QString tempDir = QDir::tempPath();
QString tempFile; QString tempFile = tempDir + QString("/temp-%1").arg(QCoreApplication::applicationPid());;
EEPROMInterface *eepromInterface = GetEepromInterface(); EEPROMInterface *eepromInterface = GetEepromInterface();
if (IS_ARM(eepromInterface->getBoard())) if (IS_ARM(eepromInterface->getBoard()))
tempFile = tempDir + "/temp.bin"; tempFile += ".bin";
else else
tempFile = tempDir + "/temp.hex"; tempFile += ".hex";
qDebug() << "MainWindow::readEeprom(): using temp file: " << tempFile;
if (readEepromFromRadio(tempFile, tr("Read Models and Settings From Radio"))) { if (readEepromFromRadio(tempFile, tr("Read Models and Settings From Radio"))) {
MdiChild *child = createMdiChild(); MdiChild *child = createMdiChild();
child->newFile(); child->newFile();
child->loadFile(tempFile, false); child->loadFile(tempFile, false);
child->show(); child->show();
unlink(tempFile.toAscii());
} }
} }
@@ -1042,7 +1045,10 @@ bool MainWindow::readEepromFromRadio(const QString filename, const QString messa
QFile file(filename); QFile file(filename);
if (file.exists()) { if (file.exists()) {
file.remove(); if (!file.remove()) {
QMessageBox::warning(this, tr("Error"), tr("Could not delete temporary file: %1").arg(filename));
return false;
}
} }
if (IS_ARM(GetCurrentFirmware()->getBoard())) { if (IS_ARM(GetCurrentFirmware()->getBoard())) {