diff options
| author | saturneric <[email protected]> | 2026-09-24 19:49:24 +0200 |
|---|---|---|
| committer | saturneric <[email protected]> | 2026-09-24 19:49:24 +0200 |
| commit | d688fb80c7de5fc0ae6150785a5998f1f31afee4 (patch) | |
| tree | c8b8b66254230c3015f263a2e92e1c341333ceca /src | |
| parent | fix(sync): time out key uploads (diff) | |
| download | modules-d688fb80c7de5fc0ae6150785a5998f1f31afee4.tar.gz modules-d688fb80c7de5fc0ae6150785a5998f1f31afee4.zip | |
fix(version-check): honor settings and prevent stalled checks
- add a 30-second transfer timeout to version check requests
- read the host setting to respect update-check preferences
- avoid duplicated SDK string allocations and memory leaks
- simplify version state updates with reusable helpers
Diffstat (limited to 'src')
| -rw-r--r-- | src/m_ver_check/BKTUSVersionCheckTask.cpp | 3 | ||||
| -rw-r--r-- | src/m_ver_check/GitHubVersionCheckTask.cpp | 3 | ||||
| -rw-r--r-- | src/m_ver_check/UpdateTab.cpp | 11 | ||||
| -rw-r--r-- | src/m_ver_check/Utils.cpp | 71 |
4 files changed, 35 insertions, 53 deletions
diff --git a/src/m_ver_check/BKTUSVersionCheckTask.cpp b/src/m_ver_check/BKTUSVersionCheckTask.cpp index 6f2da63..9cf26b9 100644 --- a/src/m_ver_check/BKTUSVersionCheckTask.cpp +++ b/src/m_ver_check/BKTUSVersionCheckTask.cpp @@ -72,6 +72,9 @@ auto BKTUSVersionCheckTask::Run() -> int { int index = 0; for (const QUrl& url : urls) { QNetworkRequest request(url); + // A check that never answers holds its task, and the tab waiting on it, + // for the rest of the run. + request.setTransferTimeout(30000); request.setHeader(QNetworkRequest::UserAgentHeader, GFAppUserAgent(GFModuleSdkContext())); auto* reply = network_manager_->get(request); diff --git a/src/m_ver_check/GitHubVersionCheckTask.cpp b/src/m_ver_check/GitHubVersionCheckTask.cpp index e0ba9d9..d2f8358 100644 --- a/src/m_ver_check/GitHubVersionCheckTask.cpp +++ b/src/m_ver_check/GitHubVersionCheckTask.cpp @@ -71,6 +71,9 @@ auto GitHubVersionCheckTask::Run() -> int { int index = 0; for (const QUrl& url : urls) { QNetworkRequest request(url); + // A check that never answers holds its task, and the tab waiting on it, + // for the rest of the run. + request.setTransferTimeout(30000); request.setHeader(QNetworkRequest::UserAgentHeader, GFAppUserAgent(GFModuleSdkContext())); QNetworkReply* reply = network_manager_->get(request); diff --git a/src/m_ver_check/UpdateTab.cpp b/src/m_ver_check/UpdateTab.cpp index 575ff7b..48d8148 100644 --- a/src/m_ver_check/UpdateTab.cpp +++ b/src/m_ver_check/UpdateTab.cpp @@ -239,11 +239,14 @@ void UpdateTab::showEvent(QShowEvent* event) { auto is_loading_done = gf::sdk::StateBool( GFModuleSdkContext(), GFGetModuleID(), "version.loading_done", 0); - auto prohibit = - gf::sdk::StateBool(GFModuleSdkContext(), "ui", - "settings.network.prohibit_update_checking", 0); + // The Host's own switch, the one the setup wizard and this module's + // settings page share. This used to read a register-table key nothing ever + // wrote, so the tab checked for updates whatever the user had chosen. + const auto prohibit = gf::sdk::Setting(GFModuleSdkContext(), GF_SETTING_HOST, + "network/prohibit_update_check", false) + .toBool(); - if ((prohibit == 0) && is_loading_done == 0) { + if (!prohibit && is_loading_done == 0) { slot_check_version_update(); } else { slot_show_version_status(); diff --git a/src/m_ver_check/Utils.cpp b/src/m_ver_check/Utils.cpp index 2cc417e..160c455 100644 --- a/src/m_ver_check/Utils.cpp +++ b/src/m_ver_check/Utils.cpp @@ -42,54 +42,27 @@ auto ExtractVersionFromRawTag(const QString& raw_tag) -> QString { } void FillGrtWithVersionInfo(const SoftwareVersion& version) { - gf::sdk::SetStateText(GFModuleSdkContext(), GFGetModuleID(), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, - "version.current_version"), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, - version.current_version.toUtf8())); - gf::sdk::SetStateText(GFModuleSdkContext(), GFGetModuleID(), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, - "version.latest_version"), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, - version.latest_version.toUtf8())); - gf::sdk::SetStateText(GFModuleSdkContext(), GFGetModuleID(), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, - "version.local_commit_hash"), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, - version.local_commit_hash.toUtf8())); + // Plain QStrings: the SDK borrows its arguments. Each of these used to be a + // GFMemStrDup() that nothing freed, a dozen leaks per update check. + auto* ctx = GFModuleSdkContext(); + const auto ns = GFModuleId(); + const auto text = [&](const char* key, const QString& value) { + gf::sdk::SetStateText(ctx, ns, QString::fromLatin1(key), value); + }; + const auto flag = [&](const char* key, bool value) { + gf::sdk::SetStateBool(ctx, ns, QString::fromLatin1(key), value); + }; - gf::sdk::SetStateBool( - GFModuleSdkContext(), GFGetModuleID(), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, - "version.current_version_publish_in_remote"), - version.current_version_publish_in_remote ? 1 : 0); - gf::sdk::SetStateBool( - GFModuleSdkContext(), GFGetModuleID(), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, - "version.current_commit_hash_publish_in_remote"), - version.current_commit_hash_publish_in_remote ? 1 : 0); - gf::sdk::SetStateBool(GFModuleSdkContext(), GFGetModuleID(), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, - "version.need_upgrade"), - version.NeedUpgrade() ? 1 : 0); - gf::sdk::SetStateBool(GFModuleSdkContext(), GFGetModuleID(), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, - "version.current_version_released"), - version.CurrentVersionReleased() ? 1 : 0); - - gf::sdk::SetStateText(GFModuleSdkContext(), GFGetModuleID(), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, - "version.release_note"), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, - version.release_note.toUtf8())); - - gf::sdk::SetStateText( - GFModuleSdkContext(), GFGetModuleID(), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, "version.api"), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, version.api.toUtf8())); - - gf::sdk::SetStateBool(GFModuleSdkContext(), GFGetModuleID(), - GFMemStrDup(GFModuleSdkContext(), GF_ARENA_NORMAL, - "version.loading_done"), - version.IsInfoValid() ? 1 : 0); + text("version.current_version", version.current_version); + text("version.latest_version", version.latest_version); + text("version.local_commit_hash", version.local_commit_hash); + flag("version.current_version_publish_in_remote", + version.current_version_publish_in_remote); + flag("version.current_commit_hash_publish_in_remote", + version.current_commit_hash_publish_in_remote); + flag("version.need_upgrade", version.NeedUpgrade()); + flag("version.current_version_released", version.CurrentVersionReleased()); + text("version.release_note", version.release_note); + text("version.api", version.api); + flag("version.loading_done", version.IsInfoValid()); }
\ No newline at end of file |
