From feb8191904b3f680d7840b0ce4f5666502bc9d80 Mon Sep 17 00:00:00 2001 From: ebbit1q Date: Sat, 12 Apr 2025 05:01:14 +0200 Subject: [PATCH] fix client crash when server goes down during registration (#5787) --- cockatrice/src/client/ui/window_main.cpp | 3 +++ cockatrice/src/server/remote/remote_client.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/cockatrice/src/client/ui/window_main.cpp b/cockatrice/src/client/ui/window_main.cpp index 89a686f61..7dabc96c6 100644 --- a/cockatrice/src/client/ui/window_main.cpp +++ b/cockatrice/src/client/ui/window_main.cpp @@ -574,6 +574,9 @@ void MainWindow::registerError(Response::ResponseCode r, QString reasonStr, quin case Response::RespRegistrationFailed: QMessageBox::critical(this, tr("Error"), tr("Registration failed for a technical problem on the server.")); break; + case Response::RespNotConnected: + QMessageBox::critical(this, tr("Error"), tr("The connection to the server has been lost.")); + break; default: QMessageBox::critical(this, tr("Error"), tr("Unknown registration error: %1").arg(static_cast(r)) + diff --git a/cockatrice/src/server/remote/remote_client.cpp b/cockatrice/src/server/remote/remote_client.cpp index 5812483ad..72391b746 100644 --- a/cockatrice/src/server/remote/remote_client.cpp +++ b/cockatrice/src/server/remote/remote_client.cpp @@ -339,6 +339,11 @@ void RemoteClient::registerResponse(const Response &response) emit registerAcceptedNeedsActivate(); doLogin(); break; + case Response::RespNotConnected: + // this response is created by the client from doDisconnectFromServer, do not call it again! + emit registerError(response.response_code(), QString::fromStdString(resp.denied_reason_str()), + static_cast(resp.denied_end_time())); + break; default: emit registerError(response.response_code(), QString::fromStdString(resp.denied_reason_str()), static_cast(resp.denied_end_time()));