Netplay: Fixed crashes when disconnect from server or stopping server while no game is loaded

This commit is contained in:
Sour 2020-05-02 12:01:47 -04:00
parent f7c170bd9b
commit 66de1ceee1
2 changed files with 9 additions and 3 deletions

View file

@ -40,7 +40,10 @@ void GameClientConnection::Shutdown()
_shutdown = true; _shutdown = true;
DisableControllers(); DisableControllers();
_console->GetControlManager()->UnregisterInputProvider(this); ControlManager* controlManager = _console->GetControlManager();
if(controlManager) {
controlManager->UnregisterInputProvider(this);
}
_console->GetNotificationManager()->SendNotification(ConsoleNotificationType::DisconnectedFromServer); _console->GetNotificationManager()->SendNotification(ConsoleNotificationType::DisconnectedFromServer);
MessageManager::DisplayMessage("NetPlay", "ConnectionLost"); MessageManager::DisplayMessage("NetPlay", "ConnectionLost");
_console->GetSettings()->ClearFlags(EmulationFlags::ForceMaxSpeed); _console->GetSettings()->ClearFlags(EmulationFlags::ForceMaxSpeed);

View file

@ -32,8 +32,11 @@ GameServer::~GameServer()
Stop(); Stop();
_console->GetControlManager()->UnregisterInputRecorder(this); ControlManager* controlManager = _console->GetControlManager();
_console->GetControlManager()->UnregisterInputProvider(this); if(controlManager) {
controlManager->UnregisterInputRecorder(this);
controlManager->UnregisterInputProvider(this);
}
} }
void GameServer::RegisterServerInput() void GameServer::RegisterServerInput()