Companion new error detected on flash (when no device found)

This commit is contained in:
Bertrand Songis
2019-05-17 19:47:35 +02:00
parent 260bceb85d
commit e036e3afa1
8 changed files with 64 additions and 56 deletions
+9 -9
View File
@@ -25,9 +25,9 @@
#include <QTime>
downloadDialog::downloadDialog(QWidget *parent, QString src, QString tgt):
DownloadDialog::DownloadDialog(QWidget *parent, QString src, QString tgt):
QDialog(parent),
ui(new Ui::downloadDialog),
ui(new Ui::DownloadDialog),
reply(nullptr),
file(nullptr),
aborted(false)
@@ -58,13 +58,13 @@ downloadDialog::downloadDialog(QWidget *parent, QString src, QString tgt):
}
}
downloadDialog::~downloadDialog()
DownloadDialog::~DownloadDialog()
{
delete ui;
delete file;
}
void downloadDialog::reject()
void DownloadDialog::reject()
{
if (reply && reply->isRunning()) {
aborted = true;
@@ -75,7 +75,7 @@ void downloadDialog::reject()
QDialog::reject();
}
void downloadDialog::httpFinished()
void DownloadDialog::httpFinished()
{
file->flush();
file->close();
@@ -98,20 +98,20 @@ void downloadDialog::httpFinished()
reject();
}
void downloadDialog::httpReadyRead()
void DownloadDialog::httpReadyRead()
{
if (file) {
file->write(reply->readAll());
}
}
void downloadDialog::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
void DownloadDialog::updateDataReadProgress(qint64 bytesRead, qint64 totalBytes)
{
ui->progressBar->setMaximum(totalBytes);
ui->progressBar->setValue(bytesRead);
}
void downloadDialog::fileError()
void DownloadDialog::fileError()
{
delete file;
file = NULL;
@@ -119,7 +119,7 @@ void downloadDialog::fileError()
}
#if 0
void downloadDialog::closeEvent( QCloseEvent * event)
void DownloadDialog::closeEvent( QCloseEvent * event)
{
// Delay closing 2 seconds to avoid unpleasant flashing download dialogs
QTime closeTime= QTime::currentTime().addSecs(2);
+16 -10
View File
@@ -28,31 +28,37 @@
#include <QFile>
namespace Ui {
class downloadDialog;
class DownloadDialog;
}
class downloadDialog : public QDialog
class DownloadDialog : public QDialog
{
Q_OBJECT
Q_OBJECT
public:
explicit downloadDialog(QWidget *parent = 0, QString src = "", QString tgt = "");
~downloadDialog();
public:
explicit DownloadDialog(QWidget *parent = 0, QString src = "", QString tgt = "");
~DownloadDialog();
public slots:
virtual void reject() override;
private slots:
private slots:
void fileError();
void httpFinished();
void httpReadyRead();
void updateDataReadProgress(qint64 bytesRead, qint64 totalBytes);
private:
private:
#if 0
void closeEvent( QCloseEvent * event);
void closeEvent(QCloseEvent * event);
#endif
Ui::downloadDialog *ui;
Ui::DownloadDialog *ui;
QNetworkAccessManager qnam;
QNetworkReply *reply;
+4 -4
View File
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>downloadDialog</class>
<widget class="QDialog" name="downloadDialog">
<class>DownloadDialog</class>
<widget class="QDialog" name="DownloadDialog">
<property name="geometry">
<rect>
<x>0</x>
@@ -53,7 +53,7 @@
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>downloadDialog</receiver>
<receiver>DownloadDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
@@ -69,7 +69,7 @@
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>downloadDialog</receiver>
<receiver>DownloadDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
+4 -4
View File
@@ -36,10 +36,10 @@
#include <unistd.h>
#endif
FlashFirmwareDialog::FlashFirmwareDialog(QWidget *parent):
QDialog(parent),
ui(new Ui::FlashFirmwareDialog),
fwName(g.profile[g.id()].fwName())
FlashFirmwareDialog::FlashFirmwareDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::FlashFirmwareDialog),
fwName(g.profile[g.id()].fwName())
{
ui->setupUi(this);
+9 -9
View File
@@ -184,7 +184,7 @@ MainWindow::~MainWindow()
{
if (windowsListActions) {
delete windowsListActions;
windowsListActions = NULL;
windowsListActions = nullptr;
}
}
@@ -293,7 +293,7 @@ void MainWindow::checkForUpdates()
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
QNetworkReply * repl = networkManager->get(request);
if (downloadDialog_forWait)
connect(downloadDialog_forWait, &downloadDialog::rejected, repl, &QNetworkReply::abort);
connect(downloadDialog_forWait, &DownloadDialog::rejected, repl, &QNetworkReply::abort);
}
void MainWindow::onUpdatesError(const QString &err)
@@ -305,7 +305,7 @@ void MainWindow::onUpdatesError(const QString &err)
void MainWindow::openUpdatesWaitDialog()
{
if (!downloadDialog_forWait) {
downloadDialog_forWait = new downloadDialog(NULL, tr("Checking for updates"));
downloadDialog_forWait = new DownloadDialog(nullptr, tr("Checking for updates"));
downloadDialog_forWait->show();
}
}
@@ -315,7 +315,7 @@ void MainWindow::closeUpdatesWaitDialog()
if (downloadDialog_forWait) {
downloadDialog_forWait->close();
delete downloadDialog_forWait;
downloadDialog_forWait = NULL;
downloadDialog_forWait = nullptr;
}
}
@@ -479,7 +479,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
if (currentVersion == 0) {
QString rn = getCurrentFirmware()->getReleaseNotesUrl();
QAbstractButton *rnButton = NULL;
QAbstractButton *rnButton = nullptr;
msgBox.setText(tr("Firmware %1 does not seem to have ever been downloaded.\nVersion %2 is available.\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.")
.arg(Firmware::getCurrentVariant()->getId()).arg(fullVersionString));
QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole);
@@ -508,7 +508,7 @@ void MainWindow::checkForFirmwareUpdateFinished(QNetworkReply * reply)
}
else if (version > currentVersion) {
QString rn = getCurrentFirmware()->getReleaseNotesUrl();
QAbstractButton *rnButton = NULL;
QAbstractButton *rnButton = nullptr;
msgBox.setText(tr("A new version of %1 firmware is available:\n - current is %2\n - newer is %3\n\nDo you want to download it now?\n\nWe recommend you view the release notes using the button below to learn about any changes that may be important to you.")
.arg(Firmware::getCurrentVariant()->getId()).arg(currentVersionString).arg(fullVersionString));
QAbstractButton *YesButton = msgBox.addButton(trUtf8("Yes"), QMessageBox::YesRole);
@@ -574,7 +574,7 @@ void MainWindow::startFirmwareDownload()
if (!filename.isEmpty()) {
g.profile[g.id()].fwName(filename);
g.flashDir(QFileInfo(filename).dir().absolutePath());
downloadDialog * dd = new downloadDialog(this, url, filename);
DownloadDialog * dd = new DownloadDialog(this, url, filename);
connect(dd, SIGNAL(accepted()), this, SLOT(firmwareDownloadAccepted()));
dd->exec();
}
@@ -1576,7 +1576,7 @@ void MainWindow::updateWindowActionTitle(const QMdiSubWindow * win, QAction * ac
void MainWindow::onSubwindowTitleChanged()
{
QMdiSubWindow * win = NULL;
QMdiSubWindow * win = nullptr;
if ((win = qobject_cast<QMdiSubWindow *>(sender()->parent())))
updateWindowActionTitle(win);
}
@@ -1591,7 +1591,7 @@ void MainWindow::onChangeWindowAction(QAction * act)
if (!act->isChecked())
return;
QMdiSubWindow * win = NULL;
QMdiSubWindow * win = nullptr;
if (act->property("window_ptr").canConvert<QMdiSubWindow *>())
win = act->property("window_ptr").value<QMdiSubWindow *>();
if (win)
+1 -3
View File
@@ -34,7 +34,6 @@ class QAction;
class QMenu;
class QMdiArea;
class QMdiSubWindow;
class QSignalMapper;
QT_END_NAMESPACE
class MainWindow : public QMainWindow
@@ -164,10 +163,9 @@ class MainWindow : public QMainWindow
bool checkProfileRadioExists(int profId);
QMdiArea *mdiArea;
QSignalMapper *windowMapper;
QString installer_fileName;
downloadDialog * downloadDialog_forWait;
DownloadDialog * downloadDialog_forWait;
unsigned int checkForUpdatesState;
QString firmwareVersionString;
+20 -16
View File
@@ -36,18 +36,18 @@
#include <unistd.h>
#endif
FlashProcess::FlashProcess(const QString &cmd, const QStringList &args, ProgressWidget *progress):
progress(progress),
cmd(cmd),
args(args),
process(new QProcess(this)),
hasErrors(false),
lfuse(0),
hfuse(0),
efuse(0),
flashPhase(READING)
FlashProcess::FlashProcess(const QString & cmd, const QStringList & args, ProgressWidget * progress):
progress(progress),
cmd(cmd),
args(args),
process(new QProcess(this)),
hasErrors(false),
lfuse(0),
hfuse(0),
efuse(0),
flashPhase(READING)
#if !__GNUC__
, killTimer(NULL)
, killTimer(nullptr)
#endif
{
connect(process, SIGNAL(started()),this, SLOT(onStarted()));
@@ -66,7 +66,7 @@ FlashProcess::~FlashProcess()
bool FlashProcess::run()
{
if (!QFile::exists(cmd)) {
QMessageBox::critical(NULL, CPN_STR_APP_NAME, tr("Executable %1 not found").arg(cmd));
QMessageBox::critical(nullptr, CPN_STR_APP_NAME, tr("Executable %1 not found").arg(cmd));
return false;
}
@@ -162,7 +162,7 @@ void FlashProcess::analyseStandardOutput(const QString &text)
if (text.contains("Complete ")) {
#if !__GNUC__
delete killTimer;
killTimer = NULL;
killTimer = nullptr;
#endif
int start = text.indexOf("Complete ");
int end = text.indexOf("%");
@@ -187,6 +187,10 @@ void FlashProcess::analyseStandardOutput(const QString &text)
if (text.contains("-E-")) {
hasErrors = true;
}
if (text.contains("Cannot open device")) {
hasErrors = true;
}
}
void FlashProcess::analyseStandardError(const QString &text)
@@ -274,15 +278,15 @@ void FlashProcess::errorWizard()
}
}
if (fwexist==false) {
QMessageBox::warning(NULL, "Companion - Tip of the day", tr("Your radio uses a %1 CPU!!!\n\nPlease check advanced burn options to set the correct cpu type.").arg(DeviceStr));
QMessageBox::warning(nullptr, "Companion - Tip of the day", tr("Your radio uses a %1 CPU!!!\n\nPlease check advanced burn options to set the correct cpu type.").arg(DeviceStr));
}
else {
Firmware *firmware = getCurrentFirmware();
QMessageBox::warning(NULL, "Companion - Tip of the day", tr("Your radio uses a %1 CPU!!!\n\nPlease select an appropriate firmware type to program it.").arg(DeviceStr)+FwStr+tr("\nYou are currently using:\n %1").arg(firmware->getName()));
QMessageBox::warning(nullptr, "Companion - Tip of the day", tr("Your radio uses a %1 CPU!!!\n\nPlease select an appropriate firmware type to program it.").arg(DeviceStr)+FwStr+tr("\nYou are currently using:\n %1").arg(firmware->getName()));
}
}
else if (output.contains("No DFU capable USB device found")){
QMessageBox::warning(NULL, "Companion - Tip of the day", tr("Your radio does not seem connected to USB or the driver is not initialized!!!."));
QMessageBox::warning(nullptr, "Companion - Tip of the day", tr("Your radio does not seem connected to USB or the driver is not initialized!!!."));
}
}
+1 -1
View File
@@ -3294,7 +3294,7 @@ Si vide, la ligne est toujours active.</translation>
<message>
<location filename="../flashfirmwaredialog.cpp" line="329"/>
<source>Flashing done</source>
<translation>Programmation Terminé</translation>
<translation>Programmation terminée</translation>
</message>
</context>
<context>