From e02706d20e98a657c65e7edbac0542606ec059aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Sat, 19 Sep 2026 09:55:00 +0200 Subject: [PATCH] [Client] Hoist room-join heal guard lookup out of response switch --- .../src/interface/widgets/tabs/tab_server.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/cockatrice/src/interface/widgets/tabs/tab_server.cpp b/cockatrice/src/interface/widgets/tabs/tab_server.cpp index 24de15ec0..fca32094c 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_server.cpp +++ b/cockatrice/src/interface/widgets/tabs/tab_server.cpp @@ -226,13 +226,13 @@ void TabServer::joinRoomFinished(const Response &r, { const bool setCurrent = pendingRoomJoins.value(roomId, extraData.toBool()); pendingRoomJoins.remove(roomId); + const bool healedJoin = healedRoomJoins.contains(roomId); + healedRoomJoins.remove(roomId); switch (r.response_code()) { case Response::RespOk: - healedRoomJoins.remove(roomId); break; case Response::RespNameNotFound: - healedRoomJoins.remove(roomId); if (setCurrent) { QMessageBox::critical(this, tr("Error"), tr("Failed to join the server room: it doesn't exist on the server.")); @@ -240,11 +240,10 @@ void TabServer::joinRoomFinished(const Response &r, emit roomJoinFailed(roomId); return; case Response::RespContextError: - if (healedRoomJoins.contains(roomId)) { + if (healedJoin) { // The rejoin below was already answered and the server still rejects the join, so - // the stale-membership heal cannot help: surface the error. The guard is released - // again so a later user-initiated join may try a fresh heal. - healedRoomJoins.remove(roomId); + // the stale-membership heal cannot help: surface the error. The guard was already + // released above so a later user-initiated join may try a fresh heal. if (setCurrent) { QMessageBox::critical( this, tr("Error"), @@ -264,7 +263,6 @@ void TabServer::joinRoomFinished(const Response &r, leaveAndRejoinRoom(roomId, setCurrent); return; case Response::RespUserLevelTooLow: - healedRoomJoins.remove(roomId); if (setCurrent) { QMessageBox::critical(this, tr("Error"), tr("You do not have the required permission to join this server room.")); @@ -272,7 +270,6 @@ void TabServer::joinRoomFinished(const Response &r, emit roomJoinFailed(roomId); return; default: - healedRoomJoins.remove(roomId); if (setCurrent) { QMessageBox::critical( this, tr("Error"),