Avoid crash if pressing close window button when networking
This commit is contained in:
@@ -1942,7 +1942,11 @@ int main(int argc, char *argv[] )
|
||||
// If the window was closed in the middle of a race, remove players,
|
||||
// so we don't crash later when StateManager tries to access input devices.
|
||||
StateManager::get()->resetActivePlayers();
|
||||
if(input_manager) delete input_manager; // if early crash avoid delete NULL
|
||||
if (input_manager)
|
||||
{
|
||||
delete input_manager;
|
||||
input_manager = NULL;
|
||||
}
|
||||
|
||||
if (STKHost::existHost())
|
||||
STKHost::get()->shutdown();
|
||||
|
||||
@@ -81,10 +81,13 @@ ClientLobby::~ClientLobby()
|
||||
void ClientLobby::clearPlayers()
|
||||
{
|
||||
StateManager::get()->resetActivePlayers();
|
||||
input_manager->getDeviceManager()->setAssignMode(NO_ASSIGN);
|
||||
input_manager->getDeviceManager()->setSinglePlayer(NULL);
|
||||
input_manager->setMasterPlayerOnly(false);
|
||||
input_manager->getDeviceManager()->clearLatestUsedDevice();
|
||||
if (input_manager)
|
||||
{
|
||||
input_manager->getDeviceManager()->setAssignMode(NO_ASSIGN);
|
||||
input_manager->getDeviceManager()->setSinglePlayer(NULL);
|
||||
input_manager->setMasterPlayerOnly(false);
|
||||
input_manager->getDeviceManager()->clearLatestUsedDevice();
|
||||
}
|
||||
} // clearPlayers
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user