Fixed several assertion failures on shutting down game

This commit is contained in:
Ivan Savenko
2022-12-16 16:19:57 +02:00
parent 291bb9b204
commit 4d628a8ba1
3 changed files with 43 additions and 40 deletions
+9
View File
@@ -585,6 +585,7 @@ void removeGUI()
GH.curInt = nullptr;
if(GH.topInt())
GH.topInt()->deactivate();
adventureInt = nullptr;
GH.listInt.clear();
GH.objsToBlit.clear();
GH.statusbar = nullptr;
@@ -1573,7 +1574,15 @@ void handleQuit(bool ask)
logConfig = nullptr;
}
std::cout << "Ending...\n";
// Workaround for assertion failure on exit:
// handleQuit() is alway called during SDL event processing
// during which, eventsM is kept locked
// this leads to assertion failure if boost::mutex is in locked state
eventsM.unlock();
exit(0);
};
+1 -9
View File
@@ -380,20 +380,12 @@ void CClient::endGame()
{
boost::unique_lock<boost::recursive_mutex> un(*CPlayerInterface::pim);
logNetwork->info("Ending current game!");
if(GH.topInt())
{
GH.topInt()->deactivate();
}
GH.listInt.clear();
GH.objsToBlit.clear();
GH.statusbar = nullptr;
logNetwork->info("Removed GUI.");
removeGUI();
vstd::clear_pointer(const_cast<CGameInfo *>(CGI)->mh);
vstd::clear_pointer(gs);
logNetwork->info("Deleted mapHandler and gameState.");
LOCPLINT = nullptr;
}
playerint.clear();
+3 -1
View File
@@ -205,7 +205,9 @@ BattleInterface::~BattleInterface()
CCS->musich->playMusicFromSet("terrain", terrain.name, true, false);
}
assert(getAnimationCondition(EAnimationEvents::ACTION) == false);
// may happen if user decided to close game while in battle
if (getAnimationCondition(EAnimationEvents::ACTION) == true)
logGlobal->error("Shutting down BattleInterface during animation playback!");
setAnimationCondition(EAnimationEvents::ACTION, false);
}