Updater: Run manual update check on separate thread

Run manual update checks on a separate thread to avoid blocking the UI,
like the automatic check already does.
This commit is contained in:
Dentomologist 2026-03-31 12:43:53 -07:00
parent cf20cdabd4
commit d5f536c595
4 changed files with 16 additions and 20 deletions

View File

@ -283,11 +283,12 @@ int main(int argc, char* argv[])
}
#endif
if (!Settings::Instance().IsBatchModeEnabled())
if (!Settings::Instance().IsBatchModeEnabled() &&
AutoUpdateChecker::SystemSupportsAutoUpdates())
{
auto* updater = new Updater(&win, Config::Get(Config::MAIN_AUTOUPDATE_UPDATE_TRACK),
Config::Get(Config::MAIN_AUTOUPDATE_HASH_OVERRIDE));
updater->start();
new Updater(&win, Config::Get(Config::MAIN_AUTOUPDATE_UPDATE_TRACK),
Config::Get(Config::MAIN_AUTOUPDATE_HASH_OVERRIDE),
AutoUpdateChecker::CheckType::Automatic);
}
retval = app.exec();

View File

@ -660,10 +660,9 @@ void MenuBar::InstallUpdateManually()
{
const std::string autoupdate_track = Config::Get(Config::MAIN_AUTOUPDATE_UPDATE_TRACK);
const std::string manual_track = autoupdate_track.empty() ? "dev" : autoupdate_track;
auto* const updater = new Updater(this->parentWidget(), manual_track,
Config::Get(Config::MAIN_AUTOUPDATE_HASH_OVERRIDE));
updater->CheckForUpdate();
new Updater(this->parentWidget(), manual_track,
Config::Get(Config::MAIN_AUTOUPDATE_HASH_OVERRIDE),
AutoUpdateChecker::CheckType::Manual);
}
void MenuBar::AddHelpMenu()

View File

@ -21,23 +21,18 @@
// Refer to docs/autoupdate_overview.md for a detailed overview of the autoupdate process
Updater::Updater(QWidget* parent, std::string update_track, std::string hash_override)
Updater::Updater(QWidget* parent, std::string update_track, std::string hash_override,
const CheckType check_type)
: m_parent(parent), m_update_track(std::move(update_track)),
m_hash_override(std::move(hash_override))
m_hash_override(std::move(hash_override)), m_check_type(check_type)
{
connect(this, &QThread::finished, this, &QObject::deleteLater);
start();
}
void Updater::run()
{
AutoUpdateChecker::CheckForUpdate(m_update_track, m_hash_override,
AutoUpdateChecker::CheckType::Automatic);
}
void Updater::CheckForUpdate()
{
AutoUpdateChecker::CheckForUpdate(m_update_track, m_hash_override,
AutoUpdateChecker::CheckType::Manual);
AutoUpdateChecker::CheckForUpdate(m_update_track, m_hash_override, m_check_type);
}
void Updater::OnUpdateAvailable(const NewVersionInformation& info)

View File

@ -17,14 +17,15 @@ class Updater : public QThread, public AutoUpdateChecker
{
Q_OBJECT
public:
explicit Updater(QWidget* parent, std::string update_track, std::string hash_override);
explicit Updater(QWidget* parent, std::string update_track, std::string hash_override,
CheckType check_type);
void run() override;
void OnUpdateAvailable(const NewVersionInformation& info) override;
void CheckForUpdate();
private:
QWidget* m_parent;
std::string m_update_track;
std::string m_hash_override;
CheckType m_check_type;
};