Make sure protocol manager exists when requesting

This commit is contained in:
Benau 2018-02-25 15:24:46 +08:00
parent c5cf87071c
commit 6c18664967
2 changed files with 9 additions and 5 deletions

View File

@ -79,7 +79,8 @@ bool Protocol::checkDataSize(Event* event, unsigned int minimum_size)
*/
void Protocol::requestStart()
{
ProtocolManager::lock()->requestStart(shared_from_this());
if (auto pm = ProtocolManager::lock())
pm->requestStart(shared_from_this());
} // requestStart
// ----------------------------------------------------------------------------
@ -87,7 +88,8 @@ void Protocol::requestStart()
*/
void Protocol::requestPause()
{
ProtocolManager::lock()->requestPause(shared_from_this());
if (auto pm = ProtocolManager::lock())
pm->requestPause(shared_from_this());
} // requestPause
// ----------------------------------------------------------------------------
@ -95,7 +97,8 @@ void Protocol::requestPause()
*/
void Protocol::requestUnpause()
{
ProtocolManager::lock()->requestUnpause(shared_from_this());
if (auto pm = ProtocolManager::lock())
pm->requestUnpause(shared_from_this());
} // requestUnpause
// ----------------------------------------------------------------------------
@ -103,7 +106,8 @@ void Protocol::requestUnpause()
*/
void Protocol::requestTerminate()
{
ProtocolManager::lock()->requestTerminate(shared_from_this());
if (auto pm = ProtocolManager::lock())
pm->requestTerminate(shared_from_this());
} // requestTerminate
// ----------------------------------------------------------------------------

View File

@ -369,7 +369,7 @@ void ClientLobby::update(float dt)
break;
case DONE:
m_state = EXITING;
ProtocolManager::lock()->requestTerminate(shared_from_this());
requestTerminate();
break;
case EXITING:
break;