1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-05 00:49:09 +02:00

Fix another case of assertion failure on exit

This commit is contained in:
Ivan Savenko
2022-12-16 16:53:21 +02:00
parent 39367473d2
commit 8665f36778

View File

@ -1508,9 +1508,7 @@ static void mainLoop()
}
}
void handleQuit(bool ask)
{
auto quitApplication = []()
static void quitApplication()
{
if(!settings["session"]["headless"].Bool())
{
@ -1574,22 +1572,25 @@ void handleQuit(bool ask)
logConfig = nullptr;
}
std::cout << "Ending...\n";
exit(0);
}
void handleQuit(bool ask)
{
if(CSH->client && LOCPLINT && ask)
{
CCS->curh->changeGraphic(ECursor::ADVENTURE, 0);
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[69], [](){
// 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);
};
if(CSH->client && LOCPLINT && ask)
{
CCS->curh->changeGraphic(ECursor::ADVENTURE, 0);
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[69], quitApplication, nullptr);
quitApplication();
}, nullptr);
}
else
{