From 59f8ac8186e12af792265138b70fb325bd7acf5a Mon Sep 17 00:00:00 2001 From: Kieran Kihn <114803508+kierankihn@users.noreply.github.com> Date: Wed, 10 Dec 2025 21:40:58 +0800 Subject: [PATCH] fix(client): add destructor to UnoClient for resource cleanup --- src/client/UnoClient.cpp | 9 ++++++++- src/client/UnoClient.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/client/UnoClient.cpp b/src/client/UnoClient.cpp index b70e5ef..2e17a43 100644 --- a/src/client/UnoClient.cpp +++ b/src/client/UnoClient.cpp @@ -141,10 +141,17 @@ namespace UNO::CLIENT { gameUI_ = std::make_shared([this](const PlayerAction &action) { this->handlePlayerAction(action); }); } + UnoClient::~UnoClient() + { + networkClient_->stop(); + if (networkThread_.joinable()) { + networkThread_.join(); + } + } + void UnoClient::run() { networkThread_ = std::thread([this]() { this->networkClient_->run(); }); gameUI_->run(); } - } // namespace UNO::CLIENT \ No newline at end of file diff --git a/src/client/UnoClient.h b/src/client/UnoClient.h index 865670d..aa6b9ca 100644 --- a/src/client/UnoClient.h +++ b/src/client/UnoClient.h @@ -44,6 +44,7 @@ namespace UNO::CLIENT { public: UnoClient(); + ~UnoClient(); void run(); };