From bed9c529d7682925dc5e1179ff82430535d524de Mon Sep 17 00:00:00 2001 From: Ben Lye Date: Fri, 28 Aug 2020 14:56:18 +0100 Subject: [PATCH] Don't close the FW update log window if the update fails (#7896) --- companion/src/flashfirmwaredialog.cpp | 66 ++++++++++++++------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/companion/src/flashfirmwaredialog.cpp b/companion/src/flashfirmwaredialog.cpp index 4650cd4c0..fc45a89ff 100644 --- a/companion/src/flashfirmwaredialog.cpp +++ b/companion/src/flashfirmwaredialog.cpp @@ -275,11 +275,12 @@ void FlashFirmwareDialog::startFlash(const QString &filename) ProgressDialog progressDialog(this, tr("Write Firmware to Radio"), CompanionIcon("write_flash.png")); // check hardware compatibility if requested + bool checkPassed = true; if (g.checkHardwareCompatibility()) { QString tempFirmware = generateProcessUniqueTempFileName("flash-check.bin"); if (!readFirmware(tempFirmware, progressDialog.progress())) { QMessageBox::warning(this, tr("Firmware check failed"), tr("Could not check firmware from radio")); - return; + checkPassed = false; } FirmwareInterface previousFirmware(tempFirmware); qunlink(tempFirmware); @@ -291,41 +292,44 @@ void FlashFirmwareDialog::startFlash(const QString &filename) qDebug() << "startFlash: removing temporary file" << filename; qunlink(filename); } - return; + checkPassed = false; } } - // backup if requested - bool result = true; - QString backupFilename; - QString backupPath; - if (backup) { - backupPath = g.profile[g.id()].pBackupDir(); - if (backupPath.isEmpty()) { - backupPath=g.backupDir(); + if (checkPassed) { + // backup if requested + bool result = true; + QString backupFilename; + QString backupPath; + if (backup) { + backupPath = g.profile[g.id()].pBackupDir(); + if (backupPath.isEmpty()) { + backupPath=g.backupDir(); + } + backupFilename = backupPath + "/backup-" + QDateTime().currentDateTime().toString("yyyy-MM-dd-HHmmss") + ".bin"; + result = readEeprom(backupFilename, progressDialog.progress()); + sleep(2); } - backupFilename = backupPath + "/backup-" + QDateTime().currentDateTime().toString("yyyy-MM-dd-HHmmss") + ".bin"; - result = readEeprom(backupFilename, progressDialog.progress()); - sleep(2); + + // flash + result = (result && writeFirmware(filename, progressDialog.progress())); + + // restore if backup requested + if (backup && result) { + sleep(2); + QString restoreFilename = generateProcessUniqueTempFileName("restore.bin"); + if (!convertEEprom(backupFilename, restoreFilename, filename)) { + QMessageBox::warning(this, tr("Conversion failed"), tr("Cannot convert Models and Settings for use with this firmware, original data will be used")); + restoreFilename = backupFilename; + } + if (!writeEeprom(restoreFilename, progressDialog.progress())) { + QMessageBox::warning(this, tr("Restore failed"), tr("Could not restore Models and Settings to Radio. The models and settings data file can be found at: %1").arg(backupFilename)); + } + } + + progressDialog.progress()->setInfo(tr("Flashing done")); } - - // flash - result = (result && writeFirmware(filename, progressDialog.progress())); - - // restore if backup requested - if (backup && result) { - sleep(2); - QString restoreFilename = generateProcessUniqueTempFileName("restore.bin"); - if (!convertEEprom(backupFilename, restoreFilename, filename)) { - QMessageBox::warning(this, tr("Conversion failed"), tr("Cannot convert Models and Settings for use with this firmware, original data will be used")); - restoreFilename = backupFilename; - } - if (!writeEeprom(restoreFilename, progressDialog.progress())) { - QMessageBox::warning(this, tr("Restore failed"), tr("Could not restore Models and Settings to Radio. The models and settings data file can be found at: %1").arg(backupFilename)); - } - } - - progressDialog.progress()->setInfo(tr("Flashing done")); + progressDialog.exec(); if (isTempFileName(filename)) {