From c8a2fd78b01703a3e6d7600243461bd7e607be6e Mon Sep 17 00:00:00 2001 From: ebbit1q Date: Mon, 17 Oct 2022 22:40:27 +0200 Subject: [PATCH] fix crash when right clicking a user's name in a replay (#4681) this happened when viewing a replay with the "view replay" option in the top menu, instead of using the replays tab while connected to a server. this uses the local game player instead of the online one which does not initialize the player info of the local spectating player, this causes a crash when opening the context menu on another player in the replay from one of their chat messages as it tries to check if you're a registered user and could add them as a friend etc. it now regards the uninitialized player info as an unregistered user and will not show these options. --- cockatrice/src/tab_supervisor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cockatrice/src/tab_supervisor.cpp b/cockatrice/src/tab_supervisor.cpp index a96b2787..c2475c21 100644 --- a/cockatrice/src/tab_supervisor.cpp +++ b/cockatrice/src/tab_supervisor.cpp @@ -687,12 +687,12 @@ void TabSupervisor::processNotifyUserEvent(const Event_NotifyUser &event) bool TabSupervisor::isOwnUserRegistered() const { - return static_cast(getUserInfo()->user_level() & ServerInfo_User::IsRegistered); + return userInfo != nullptr && (userInfo->user_level() & ServerInfo_User::IsRegistered) != 0; } QString TabSupervisor::getOwnUsername() const { - return userInfo ? QString::fromStdString(userInfo->name()) : QString(); + return userInfo != nullptr ? QString::fromStdString(userInfo->name()) : QString(); } bool TabSupervisor::isUserBuddy(const QString &userName) const