From 18637647135d2074c5ded2e9bc823c349d34e237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= <44814898+BruebachL@users.noreply.github.com> Date: Fri, 6 Nov 2026 12:04:17 +0100 Subject: [PATCH] [DeckSync] Move the client signal handlers out of the constructor lambdas --- .../interface/deck_sync/deck_sync_manager.cpp | 45 +++++++++++-------- .../interface/deck_sync/deck_sync_manager.h | 5 ++- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/cockatrice/src/interface/deck_sync/deck_sync_manager.cpp b/cockatrice/src/interface/deck_sync/deck_sync_manager.cpp index 060ed47ff..72e8d0f2d 100644 --- a/cockatrice/src/interface/deck_sync/deck_sync_manager.cpp +++ b/cockatrice/src/interface/deck_sync/deck_sync_manager.cpp @@ -106,25 +106,32 @@ DeckSyncManager::DeckSyncManager(AbstractClient *_client, ColorIdentityProvider if (client == nullptr) { return; } - connect(client, &AbstractClient::statusChanged, this, [this](ClientStatus status) { - if (status == StatusDisconnected) { - offline = true; - debounceTimer->stop(); - // A run cannot survive the session it was started on: the in-flight - // command comes back RespNotConnected, the remaining queue would be - // sent on a dead client, and a re-login as another account would - // receive this profile's uploads and deletes. - if (syncing) { - activeConflict = ActiveConflict(); - failSync(tr("Disconnected.")); - } - } - }); - connect(client, &AbstractClient::userInfoChanged, this, [this](const ServerInfo_User &userInfo) { - offline = false; - serverUsername = QString::fromStdString(userInfo.name()); - autoSyncSoon(); - }); + connect(client, &AbstractClient::statusChanged, this, &DeckSyncManager::onClientStatusChanged); + connect(client, &AbstractClient::userInfoChanged, this, &DeckSyncManager::onUserInfoChanged); +} + +void DeckSyncManager::onClientStatusChanged(ClientStatus status) +{ + if (status != StatusDisconnected) { + return; + } + offline = true; + debounceTimer->stop(); + // A run cannot survive the session it was started on: the in-flight + // command comes back RespNotConnected, the remaining queue would be + // sent on a dead client, and a re-login as another account would + // receive this profile's uploads and deletes. + if (syncing) { + activeConflict = ActiveConflict(); + failSync(tr("Disconnected.")); + } +} + +void DeckSyncManager::onUserInfoChanged(const ServerInfo_User &userInfo) +{ + offline = false; + serverUsername = QString::fromStdString(userInfo.name()); + autoSyncSoon(); } void DeckSyncManager::setServerIdentity(const QString &host, int port, const QString &username) diff --git a/cockatrice/src/interface/deck_sync/deck_sync_manager.h b/cockatrice/src/interface/deck_sync/deck_sync_manager.h index 7d3c6358d..dd443e9c4 100644 --- a/cockatrice/src/interface/deck_sync/deck_sync_manager.h +++ b/cockatrice/src/interface/deck_sync/deck_sync_manager.h @@ -17,15 +17,16 @@ #include #include #include +#include #include -class AbstractClient; class CommandContainer; class DeckList; class QFileSystemWatcher; class QTimer; class Response; class ServerInfo_DeckStorage_Folder; +class ServerInfo_User; /** * @class DeckSyncManager @@ -169,6 +170,8 @@ private: [[nodiscard]] bool canAutoRun() const; void onDebounceTimeout(); void onWatchedPathChanged(const QString &path); + void onClientStatusChanged(ClientStatus status); + void onUserInfoChanged(const ServerInfo_User &userInfo); void refreshWatcher(); void refreshInterval(); [[nodiscard]] DeckSyncProfile buildProfile() const;