Cockatrice/cockatrice
BruebachL dd7ee3541c
[PictureLoader] Keep the download log from going quadratic (#7766)
* [PictureLoader] Keep the download log from going quadratic

A fast scrollbar sweep over the visual card database requests a picture for
every cell it paints, so one gesture can ask for thousands of downloads. The
status bar built a seven-widget log entry for each of them and answered every
completion with findChildren() over the whole, unbounded log, rebuilding
url.toString() per child: O(n) per completion, O(n^2) per burst.

Profiling a sweep on master put 47% of all cycles on the GUI thread, with
qt_qFindChildren_helper at 12.4% of the process (a quarter of that thread) and
QWidgetPrivate::reparentFocusChildren at 4.1%. LagMonitor reported stalls of
3-18 s, growing with the backlog.

Keep at most MAX_LOG_ENTRIES entries and index them by URL, so a completion
and the 1 Hz cleanup only visit the matching entries. The progress bar follows
the entries that remain: dropping a finished entry moves both counters back,
dropping a pending one only its maximum. The log is a diagnostic view, not a
queue - the downloads themselves are unaffected.

* fixup! [PictureLoader] Keep the download log from going quadratic

Make the URL index a QMultiHash and say why: a deferred retry re-queues the same URL while its first log entry is still pending, so one URL can back several live entries.

---------

Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
2026-11-03 10:17:53 +01:00
..
resources [Themes] Encode home backgrounds as JPEG to slim the repo (#7346) 2026-09-24 18:40:04 +02:00
sounds Add cmake format (#4618) 2022-05-08 21:22:43 +02:00
src [PictureLoader] Keep the download log from going quadratic (#7766) 2026-11-03 10:17:53 +01:00
themes [Themes] Encode home backgrounds as JPEG to slim the repo (#7346) 2026-09-24 18:40:04 +02:00
translations Updates for project Cockatrice and language ru (#7561) 2026-10-17 16:43:14 +02:00
.qdevelop icon_draw and icon_untap added, icon_general and icon_messages modified 2009-07-31 13:37:16 +02:00
CMakeLists.txt [VisualDatabase] Draw the card grid with a model/view (#7701) 2026-11-02 08:35:58 +01:00
cockatrice-cod.xml Define Cockatrice as an editor/handler for .cod files and cockatrice:// protocol on all platforms (#6775) 2026-08-08 19:02:19 +02:00
cockatrice.desktop fix the desktop file, removing the invalid key (#7406) 2026-10-10 17:15:10 +02:00
cockatrice.qrc [Themes] Encode home backgrounds as JPEG to slim the repo (#7346) 2026-09-24 18:40:04 +02:00
cockatrice.rc Included uninstaller for Windows version 2010-09-17 15:26:07 +02:00
cockatrice_en@source.ts Update translation source strings (#7397) 2026-10-04 21:08:47 +02:00