mirror of
https://github.com/azahar-emu/azahar.git
synced 2026-06-05 18:23:39 -04:00
* Qt: Improve update checker system to prevent downgrades * Code cleanup * Return 0 as fallback * Satisfy clang-format --------- Co-authored-by: OpenSauce04 <opensauce04@gmail.com>
This commit is contained in:
parent
784fc8cca9
commit
d9f28c5b2a
1 changed files with 15 additions and 2 deletions
|
|
@ -180,12 +180,21 @@ bool IsPrereleaseBuild() {
|
|||
}
|
||||
|
||||
#ifdef ENABLE_QT_UPDATE_CHECKER
|
||||
bool ShouldCheckForPrereleaseUpdates() {
|
||||
static bool ShouldCheckForPrereleaseUpdates() {
|
||||
const bool update_channel = UISettings::values.update_check_channel.GetValue();
|
||||
const bool using_prerelease_channel =
|
||||
(update_channel == UISettings::UpdateCheckChannels::PRERELEASE);
|
||||
return (IsPrereleaseBuild() || using_prerelease_channel);
|
||||
}
|
||||
|
||||
static int GetMajorVersion(const std::string& version) {
|
||||
size_t dot = version.find('.');
|
||||
try {
|
||||
return std::stoi(version.substr(0, dot));
|
||||
} catch (...) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
GMainWindow::GMainWindow(Core::System& system_)
|
||||
|
|
@ -422,7 +431,11 @@ GMainWindow::GMainWindow(Core::System& system_)
|
|||
UpdateChecker::GetLatestRelease(ShouldCheckForPrereleaseUpdates());
|
||||
|
||||
if (latest_release_tag && latest_release_tag.value() != Common::g_build_fullname) {
|
||||
return QString::fromStdString(latest_release_tag.value());
|
||||
const int latest_major_version = GetMajorVersion(latest_release_tag.value());
|
||||
const int current_major_version = GetMajorVersion(Common::g_build_fullname);
|
||||
if (current_major_version <= latest_major_version) {
|
||||
return QString::fromStdString(latest_release_tag.value());
|
||||
}
|
||||
}
|
||||
return QString{};
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue