From b2bb85b1a28ee30512beba066a863031fc004157 Mon Sep 17 00:00:00 2001 From: matbe766 Date: Thu, 2 Oct 2025 11:59:09 +0200 Subject: [PATCH] Avoid QProgressBar overflow by normalizing to kilobytes (fixes #4341) (#4354) * qt: normalize large progress totals to kilobytes to avoid QProgressBar overflow (#4341); docs: update CONTRIBUTORS * update * revert: keep ProgressManager generic; no autoscaling in progress.py * revert: keep ProgressManager generic; do scaling only in full sync * Simplify sync progress update by scaling to KB, fix CONTRIBUTORS --- CONTRIBUTORS | 2 ++ qt/aqt/sync.py | 13 +++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index a6334b0d9..c66588274 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -247,6 +247,8 @@ Hanna Nilsén Elias Johansson Lara Toby Penner Danilo Spillebeen +Matbe766 + ******************** diff --git a/qt/aqt/sync.py b/qt/aqt/sync.py index 9b29ada20..75bdeca89 100644 --- a/qt/aqt/sync.py +++ b/qt/aqt/sync.py @@ -209,11 +209,20 @@ def on_full_sync_timer(mw: aqt.main.AnkiQt, label: str) -> None: return sync_progress = progress.full_sync + # If we've reached total, show the "checking" label if sync_progress.transferred == sync_progress.total: label = tr.sync_checking() + + total = sync_progress.total + transferred = sync_progress.transferred + + # Scale both to kilobytes with floor division + max_for_bar = total // 1024 + value_for_bar = transferred // 1024 + mw.progress.update( - value=sync_progress.transferred, - max=sync_progress.total, + value=value_for_bar, + max=max_for_bar, process=False, label=label, )