Skip to content

Commit d5f536c

Browse files
committed
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.
1 parent cf20cda commit d5f536c

4 files changed

Lines changed: 16 additions & 20 deletions

File tree

Source/Core/DolphinQt/Main.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,12 @@ int main(int argc, char* argv[])
283283
}
284284
#endif
285285

286-
if (!Settings::Instance().IsBatchModeEnabled())
286+
if (!Settings::Instance().IsBatchModeEnabled() &&
287+
AutoUpdateChecker::SystemSupportsAutoUpdates())
287288
{
288-
auto* updater = new Updater(&win, Config::Get(Config::MAIN_AUTOUPDATE_UPDATE_TRACK),
289-
Config::Get(Config::MAIN_AUTOUPDATE_HASH_OVERRIDE));
290-
updater->start();
289+
new Updater(&win, Config::Get(Config::MAIN_AUTOUPDATE_UPDATE_TRACK),
290+
Config::Get(Config::MAIN_AUTOUPDATE_HASH_OVERRIDE),
291+
AutoUpdateChecker::CheckType::Automatic);
291292
}
292293

293294
retval = app.exec();

Source/Core/DolphinQt/MenuBar.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -660,10 +660,9 @@ void MenuBar::InstallUpdateManually()
660660
{
661661
const std::string autoupdate_track = Config::Get(Config::MAIN_AUTOUPDATE_UPDATE_TRACK);
662662
const std::string manual_track = autoupdate_track.empty() ? "dev" : autoupdate_track;
663-
auto* const updater = new Updater(this->parentWidget(), manual_track,
664-
Config::Get(Config::MAIN_AUTOUPDATE_HASH_OVERRIDE));
665-
666-
updater->CheckForUpdate();
663+
new Updater(this->parentWidget(), manual_track,
664+
Config::Get(Config::MAIN_AUTOUPDATE_HASH_OVERRIDE),
665+
AutoUpdateChecker::CheckType::Manual);
667666
}
668667

669668
void MenuBar::AddHelpMenu()

Source/Core/DolphinQt/Updater.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,18 @@
2121

2222
// Refer to docs/autoupdate_overview.md for a detailed overview of the autoupdate process
2323

24-
Updater::Updater(QWidget* parent, std::string update_track, std::string hash_override)
24+
Updater::Updater(QWidget* parent, std::string update_track, std::string hash_override,
25+
const CheckType check_type)
2526
: m_parent(parent), m_update_track(std::move(update_track)),
26-
m_hash_override(std::move(hash_override))
27+
m_hash_override(std::move(hash_override)), m_check_type(check_type)
2728
{
2829
connect(this, &QThread::finished, this, &QObject::deleteLater);
30+
start();
2931
}
3032

3133
void Updater::run()
3234
{
33-
AutoUpdateChecker::CheckForUpdate(m_update_track, m_hash_override,
34-
AutoUpdateChecker::CheckType::Automatic);
35-
}
36-
37-
void Updater::CheckForUpdate()
38-
{
39-
AutoUpdateChecker::CheckForUpdate(m_update_track, m_hash_override,
40-
AutoUpdateChecker::CheckType::Manual);
35+
AutoUpdateChecker::CheckForUpdate(m_update_track, m_hash_override, m_check_type);
4136
}
4237

4338
void Updater::OnUpdateAvailable(const NewVersionInformation& info)

Source/Core/DolphinQt/Updater.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ class Updater : public QThread, public AutoUpdateChecker
1717
{
1818
Q_OBJECT
1919
public:
20-
explicit Updater(QWidget* parent, std::string update_track, std::string hash_override);
20+
explicit Updater(QWidget* parent, std::string update_track, std::string hash_override,
21+
CheckType check_type);
2122

2223
void run() override;
2324
void OnUpdateAvailable(const NewVersionInformation& info) override;
24-
void CheckForUpdate();
2525

2626
private:
2727
QWidget* m_parent;
2828
std::string m_update_track;
2929
std::string m_hash_override;
30+
CheckType m_check_type;
3031
};

0 commit comments

Comments
 (0)