From 72ff5cd4452b51648d91f952c5820cc9b6dfab68 Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Wed, 3 Aug 2022 19:45:13 +0200 Subject: [PATCH] yuzu: Fix crash on shutdown Previously, accessing the room_network when it was already freed would crash the emulator on shutdown. Co-Authored-By: Narr the Reg <5944268+german77@users.noreply.github.com> --- src/yuzu/main.cpp | 3 +-- src/yuzu/multiplayer/state.cpp | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 8bd1f92f7c..e103df977a 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -492,8 +492,6 @@ GMainWindow::~GMainWindow() { delete render_window; } - system->GetRoomNetwork().Shutdown(); - #ifdef __linux__ ::close(sig_interrupt_fds[0]); ::close(sig_interrupt_fds[1]); @@ -3831,6 +3829,7 @@ void GMainWindow::closeEvent(QCloseEvent* event) { render_window->close(); multiplayer_state->Close(); + system->GetRoomNetwork().Shutdown(); QWidget::closeEvent(event); } diff --git a/src/yuzu/multiplayer/state.cpp b/src/yuzu/multiplayer/state.cpp index 84ea1aa4cb..dba76b22b0 100644 --- a/src/yuzu/multiplayer/state.cpp +++ b/src/yuzu/multiplayer/state.cpp @@ -59,7 +59,9 @@ MultiplayerState::MultiplayerState(QWidget* parent, QStandardItemModel* game_lis }); } -MultiplayerState::~MultiplayerState() { +MultiplayerState::~MultiplayerState() = default; + +void MultiplayerState::Close() { if (state_callback_handle) { if (auto member = room_network.GetRoomMember().lock()) { member->Unbind(state_callback_handle); @@ -71,9 +73,6 @@ MultiplayerState::~MultiplayerState() { member->Unbind(error_callback_handle); } } -} - -void MultiplayerState::Close() { if (host_room) { host_room->close(); }