From 5575b3475bdbad44f5e05f1b7755859a14f9a84c Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sun, 23 Feb 2020 01:10:29 -0600 Subject: Qt UI: Fix issues identified by static analysis --- ui/qt5/datetimepage.cc | 7 +++---- ui/qt5/horizonwizard.cc | 4 ++-- ui/qt5/networkingpage.cc | 16 ++++++++-------- ui/qt5/networkingpage.hh | 4 ++-- ui/qt5/partitiondiskpage.cc | 2 +- ui/qt5/stepprogresswidget.cc | 20 ++++++++++---------- 6 files changed, 26 insertions(+), 27 deletions(-) (limited to 'ui') diff --git a/ui/qt5/datetimepage.cc b/ui/qt5/datetimepage.cc index 7db62bf..fb027aa 100644 --- a/ui/qt5/datetimepage.cc +++ b/ui/qt5/datetimepage.cc @@ -160,10 +160,9 @@ DateTimePage::DateTimePage(QWidget *parent) : HorizonWizardPage(parent) { clock_settime(CLOCK_REALTIME, &ts); } }); - connect(timeEdit, &QTimeEdit::timeChanged, [=](const QTime &time) { - if(timeEdit->isEnabled() && time != QTime::currentTime()) { - QDateTime *newDT = new QDateTime(QDate::currentDate(), time, - Qt::UTC); + connect(timeEdit, &QTimeEdit::timeChanged, [=](const QTime &qtime) { + if(timeEdit->isEnabled() && qtime != QTime::currentTime()) { + QDateTime *newDT = new QDateTime(QDate::currentDate(), qtime); struct timespec ts = {newDT->toSecsSinceEpoch(), 0}; clock_settime(CLOCK_REALTIME, &ts); } diff --git a/ui/qt5/horizonwizard.cc b/ui/qt5/horizonwizard.cc index d181a80..2ef9e79 100644 --- a/ui/qt5/horizonwizard.cc +++ b/ui/qt5/horizonwizard.cc @@ -383,7 +383,7 @@ QString nameForPartitionOnDisk(const std::string &dev, int part) { /*! Determine the correct disk label based on the target platform. */ -QStringList eraseDiskForArch(const std::string raw_disk, +QStringList eraseDiskForArch(const std::string &raw_disk, HorizonWizard::Arch arch, HorizonWizard::Subarch subarch) { QString disk = QString::fromStdString(raw_disk); @@ -414,7 +414,7 @@ QStringList eraseDiskForArch(const std::string raw_disk, /*! Determine the correct boot disk layout based on the target platform. */ -QStringList bootForArch(const std::string raw_disk, HorizonWizard::Arch arch, +QStringList bootForArch(const std::string &raw_disk, HorizonWizard::Arch arch, HorizonWizard::Subarch subarch, int *start) { QString disk = QString::fromStdString(raw_disk); diff --git a/ui/qt5/networkingpage.cc b/ui/qt5/networkingpage.cc index 5e72dba..589ad5f 100644 --- a/ui/qt5/networkingpage.cc +++ b/ui/qt5/networkingpage.cc @@ -22,14 +22,20 @@ NetworkingPage::NetworkingPage(QWidget *parent) : HorizonWizardPage(parent) { loadWatermark("network"); setTitle(tr("Networking Setup")); + + radioGroup = new QButtonGroup(this); + + simple = new QRadioButton(tr("&Automatic - my computer connects to the Internet directly\n" + "or via a modem/router.")); + advanced = new QRadioButton(tr("&Manual - my computer connects to an enterprise network,\n" + "or I use a static IP address, VPN, or 802.1X security.")); + skip = new QRadioButton(tr("&Skip - I don't want to connect to a network or the Internet.")); } void NetworkingPage::initializePage() { QLabel *descLabel; QVBoxLayout *layout; - radioGroup = new QButtonGroup(this); - #ifdef HAS_INSTALL_ENV if(horizonWizard()->interfaces.empty()) { descLabel = new QLabel(tr( @@ -52,15 +58,9 @@ void NetworkingPage::initializePage() { if(!horizonWizard()->interfaces.empty()) #endif /* HAS_INSTALL_ENV */ { - simple = new QRadioButton(tr("&Automatic - my computer connects to the Internet directly\n" - "or via a modem/router.")); - advanced = new QRadioButton(tr("&Manual - my computer connects to an enterprise network,\n" - "or I use a static IP address, VPN, or 802.1X security.")); radioGroup->addButton(simple); radioGroup->addButton(advanced); } - skip = new QRadioButton(tr("&Skip - I don't want to connect to a network or the Internet.")); - radioGroup->addButton(skip); QObject::connect(radioGroup, static_cast(&QButtonGroup::buttonClicked), diff --git a/ui/qt5/networkingpage.hh b/ui/qt5/networkingpage.hh index a5f08e5..7bd03cf 100644 --- a/ui/qt5/networkingpage.hh +++ b/ui/qt5/networkingpage.hh @@ -23,8 +23,8 @@ public: NetworkingPage(QWidget *parent = nullptr); void initializePage() override; - bool isComplete() const; - int nextId() const; + bool isComplete() const override; + int nextId() const override; private: QButtonGroup *radioGroup; QRadioButton *simple, *advanced, *skip; diff --git a/ui/qt5/partitiondiskpage.cc b/ui/qt5/partitiondiskpage.cc index c5eb17f..af66f7d 100644 --- a/ui/qt5/partitiondiskpage.cc +++ b/ui/qt5/partitiondiskpage.cc @@ -45,7 +45,7 @@ QString prettySizeForMB(uint32_t mbyte) { size /= 1024; prefix++; } - while(prefix > sizeof(prefixes)) { + while(prefix >= sizeof(prefixes)) { size *= 1024; prefix--; } diff --git a/ui/qt5/stepprogresswidget.cc b/ui/qt5/stepprogresswidget.cc index b6e1921..445cd2e 100644 --- a/ui/qt5/stepprogresswidget.cc +++ b/ui/qt5/stepprogresswidget.cc @@ -78,25 +78,25 @@ QPixmap StepProgressWidget::loadDPIAwarePixmap(QString pixmap, QString type) { } void StepProgressWidget::setStepStatus(int16_t step, Status status) { - QLabel *stat = statuses.at(step); - QLabel *info = infos.at(step); + QLabel *statLabel = statuses.at(step); + QLabel *infoLabel = infos.at(step); switch(status) { case NotStarted: - stat->clear(); - info->setFont(normalFont); + statLabel->clear(); + infoLabel->setFont(normalFont); break; case InProgress: - stat->setPixmap(loadDPIAwarePixmap("status-current", ".svg")); - info->setFont(boldFont); + statLabel->setPixmap(loadDPIAwarePixmap("status-current", ".svg")); + infoLabel->setFont(boldFont); break; case Finished: - stat->setPixmap(loadDPIAwarePixmap("status-success", ".svg")); - info->setFont(normalFont); + statLabel->setPixmap(loadDPIAwarePixmap("status-success", ".svg")); + infoLabel->setFont(normalFont); break; case Failed: - stat->setPixmap(loadDPIAwarePixmap("status-issue", ".svg")); - info->setFont(boldFont); + statLabel->setPixmap(loadDPIAwarePixmap("status-issue", ".svg")); + infoLabel->setFont(boldFont); break; } } -- cgit v1.2.3-60-g2f50