From 38749d713d9fd2c7f932d6dafa5cf6184373702a Mon Sep 17 00:00:00 2001 From: elecpower Date: Fri, 26 Aug 2022 13:42:23 +1000 Subject: [PATCH] Invoke interactive update mode if any updates found on startup --- companion/src/updates/updateinterface.cpp | 28 +---------------------- companion/src/updates/updateinterface.h | 2 -- companion/src/updates/updates.cpp | 11 +-------- 3 files changed, 2 insertions(+), 39 deletions(-) diff --git a/companion/src/updates/updateinterface.cpp b/companion/src/updates/updateinterface.cpp index 0a46cf083..66c8f909e 100644 --- a/companion/src/updates/updateinterface.cpp +++ b/companion/src/updates/updateinterface.cpp @@ -176,19 +176,6 @@ UpdateInterface::~UpdateInterface() delete runParams; } -bool UpdateInterface::autoUpdate(ProgressWidget * progress) -{ - this->progress = progress; - - if (g.component[m_settingsIdx].checkForUpdate() && !isLatestRelease()) { - runParams->data.flags |= UPDFLG_Update; - runParams->data.updateRelease = latestRelease(); - return update(); - } - - return true; -} - bool UpdateInterface::manualUpdate(ProgressWidget * progress) { this->progress = progress; @@ -241,7 +228,7 @@ bool UpdateInterface::update() reportProgress(tr("%1 update successful").arg(name), QtInfoMsg); - if (!progress) // auto update + if (!progress) QMessageBox::information(this, CPN_STR_APP_NAME, tr("%1 update successful").arg(name)); return true; @@ -1559,19 +1546,6 @@ const QStringList UpdateFactories::releases(const QString & name) return ret; } -bool UpdateFactories::autoUpdate(ProgressWidget * progress) -{ - bool ok = false; - - foreach (UpdateFactoryInterface * factory, registeredUpdateFactories) { - ok = factory->instance()->autoUpdate(progress); - if (!ok) - break; - } - - return ok; -} - bool UpdateFactories::manualUpdate(ProgressWidget * progress) { bool ok = false; diff --git a/companion/src/updates/updateinterface.h b/companion/src/updates/updateinterface.h index 8fd8cbc41..d09924d62 100644 --- a/companion/src/updates/updateinterface.h +++ b/companion/src/updates/updateinterface.h @@ -135,7 +135,6 @@ class UpdateInterface : public QWidget QString updateDir; int logLevel; - virtual bool autoUpdate(ProgressWidget * progress = nullptr); virtual bool manualUpdate(ProgressWidget * progress = nullptr); virtual bool update(); @@ -283,7 +282,6 @@ class UpdateFactories : public QWidget const QString latestRelease(const QString & name); const QStringList releases(const QString & name); - bool autoUpdate(ProgressWidget * progress = nullptr); bool manualUpdate(ProgressWidget * progress = nullptr); const bool isUpdatesAvailable(QStringList & names); diff --git a/companion/src/updates/updates.cpp b/companion/src/updates/updates.cpp index f05fe006c..6f0891674 100644 --- a/companion/src/updates/updates.cpp +++ b/companion/src/updates/updates.cpp @@ -71,16 +71,7 @@ void Updates::autoUpdates() if (QMessageBox::question(parentWidget(), CPN_STR_APP_NAME % ": " % tr("Checking for Updates"), tr("Updates available for:\n %1\n\nUpdate now?").arg(list.join("\n ")), (QMessageBox::Yes | QMessageBox::No), QMessageBox::No) == QMessageBox::Yes) { - - factories->resetAllRunEnvironments(); - - if (!factories->autoUpdate()) { - QMessageBox::warning(this, CPN_STR_APP_NAME, tr("Updates finished with errors")); - } - else { - QMessageBox::information(this, CPN_STR_APP_NAME, tr("Updates finished successfully")); - checkRunSDSync(); - } + manualUpdates(); } }