From facb9a030f46c3d516eb5e1b35ce7f23a92c348a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Mon, 25 Nov 2024 16:04:51 +0100 Subject: [PATCH] Clear timer on updateDisplay. --- .../ui/widgets/printing_selector/printing_selector.cpp | 5 ++++- .../client/ui/widgets/printing_selector/printing_selector.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.cpp b/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.cpp index 8081721ff..6a149deeb 100644 --- a/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.cpp +++ b/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.cpp @@ -26,6 +26,7 @@ PrintingSelector::PrintingSelector(QWidget *parent, setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); layout = new QVBoxLayout(); setLayout(layout); + timer = new QTimer(this); sortToolBar = new QHBoxLayout(this); @@ -103,6 +104,8 @@ void PrintingSelector::updateSortOrder() void PrintingSelector::updateDisplay() { + timer->stop(); + timer = new QTimer(this); flowWidget->clearLayout(); if (selectedCard != nullptr) { setWindowTitle(selectedCard->getName()); @@ -301,7 +304,7 @@ void PrintingSelector::getAllSetsForCurrentCard() // Defer widget creation currentIndex = 0; - QTimer *timer = new QTimer(this); + connect(timer, &QTimer::timeout, this, [=]() mutable { for (int i = 0; i < BATCH_SIZE && currentIndex < prependedSets.size(); ++i, ++currentIndex) { auto *cardDisplayWidget = diff --git a/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.h b/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.h index cf5779ab8..0747454f0 100644 --- a/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.h +++ b/cockatrice/src/client/ui/widgets/printing_selector/printing_selector.h @@ -63,6 +63,7 @@ private: QTreeView *deckView; CardInfoPtr selectedCard; QString currentZone; + QTimer *timer; int currentIndex = 0; void selectCard(int changeBy); };