mirror of
https://github.com/vcmi/vcmi.git
synced 2025-07-07 00:58:39 +02:00
Fix another case of assertion failure on exit
This commit is contained in:
167
client/CMT.cpp
167
client/CMT.cpp
@ -582,13 +582,13 @@ void printInfoAboutIntObject(const CIntObject *obj, int level)
|
|||||||
void removeGUI()
|
void removeGUI()
|
||||||
{
|
{
|
||||||
// CClient::endGame
|
// CClient::endGame
|
||||||
GH.curInt = nullptr;
|
GH.curInt = nullptr;
|
||||||
if(GH.topInt())
|
if(GH.topInt())
|
||||||
GH.topInt()->deactivate();
|
GH.topInt()->deactivate();
|
||||||
adventureInt = nullptr;
|
adventureInt = nullptr;
|
||||||
GH.listInt.clear();
|
GH.listInt.clear();
|
||||||
GH.objsToBlit.clear();
|
GH.objsToBlit.clear();
|
||||||
GH.statusbar = nullptr;
|
GH.statusbar = nullptr;
|
||||||
logGlobal->info("Removed GUI.");
|
logGlobal->info("Removed GUI.");
|
||||||
|
|
||||||
LOCPLINT = nullptr;
|
LOCPLINT = nullptr;
|
||||||
@ -1508,88 +1508,89 @@ static void mainLoop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void quitApplication()
|
||||||
|
{
|
||||||
|
if(!settings["session"]["headless"].Bool())
|
||||||
|
{
|
||||||
|
if(CSH->client)
|
||||||
|
CSH->endGameplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
GH.listInt.clear();
|
||||||
|
GH.objsToBlit.clear();
|
||||||
|
|
||||||
|
CMM.reset();
|
||||||
|
|
||||||
|
if(!settings["session"]["headless"].Bool())
|
||||||
|
{
|
||||||
|
// cleanup, mostly to remove false leaks from analyzer
|
||||||
|
if(CCS)
|
||||||
|
{
|
||||||
|
CCS->musich->release();
|
||||||
|
CCS->soundh->release();
|
||||||
|
|
||||||
|
vstd::clear_pointer(CCS);
|
||||||
|
}
|
||||||
|
CMessage::dispose();
|
||||||
|
|
||||||
|
vstd::clear_pointer(graphics);
|
||||||
|
}
|
||||||
|
|
||||||
|
vstd::clear_pointer(VLC);
|
||||||
|
|
||||||
|
vstd::clear_pointer(console);// should be removed after everything else since used by logging
|
||||||
|
|
||||||
|
boost::this_thread::sleep(boost::posix_time::milliseconds(750));//???
|
||||||
|
if(!settings["session"]["headless"].Bool())
|
||||||
|
{
|
||||||
|
if(settings["general"]["notifications"].Bool())
|
||||||
|
{
|
||||||
|
NotificationHandler::destroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanupRenderer();
|
||||||
|
|
||||||
|
if(nullptr != mainRenderer)
|
||||||
|
{
|
||||||
|
SDL_DestroyRenderer(mainRenderer);
|
||||||
|
mainRenderer = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nullptr != mainWindow)
|
||||||
|
{
|
||||||
|
SDL_DestroyWindow(mainWindow);
|
||||||
|
mainWindow = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_Quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(logConfig != nullptr)
|
||||||
|
{
|
||||||
|
logConfig->deconfigure();
|
||||||
|
delete logConfig;
|
||||||
|
logConfig = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << "Ending...\n";
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
void handleQuit(bool ask)
|
void handleQuit(bool ask)
|
||||||
{
|
{
|
||||||
auto quitApplication = []()
|
|
||||||
{
|
|
||||||
if(!settings["session"]["headless"].Bool())
|
|
||||||
{
|
|
||||||
if(CSH->client)
|
|
||||||
CSH->endGameplay();
|
|
||||||
}
|
|
||||||
|
|
||||||
GH.listInt.clear();
|
|
||||||
GH.objsToBlit.clear();
|
|
||||||
|
|
||||||
CMM.reset();
|
|
||||||
|
|
||||||
if(!settings["session"]["headless"].Bool())
|
|
||||||
{
|
|
||||||
// cleanup, mostly to remove false leaks from analyzer
|
|
||||||
if(CCS)
|
|
||||||
{
|
|
||||||
CCS->musich->release();
|
|
||||||
CCS->soundh->release();
|
|
||||||
|
|
||||||
vstd::clear_pointer(CCS);
|
|
||||||
}
|
|
||||||
CMessage::dispose();
|
|
||||||
|
|
||||||
vstd::clear_pointer(graphics);
|
|
||||||
}
|
|
||||||
|
|
||||||
vstd::clear_pointer(VLC);
|
|
||||||
|
|
||||||
vstd::clear_pointer(console);// should be removed after everything else since used by logging
|
|
||||||
|
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(750));//???
|
|
||||||
if(!settings["session"]["headless"].Bool())
|
|
||||||
{
|
|
||||||
if(settings["general"]["notifications"].Bool())
|
|
||||||
{
|
|
||||||
NotificationHandler::destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanupRenderer();
|
|
||||||
|
|
||||||
if(nullptr != mainRenderer)
|
|
||||||
{
|
|
||||||
SDL_DestroyRenderer(mainRenderer);
|
|
||||||
mainRenderer = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(nullptr != mainWindow)
|
|
||||||
{
|
|
||||||
SDL_DestroyWindow(mainWindow);
|
|
||||||
mainWindow = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_Quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(logConfig != nullptr)
|
|
||||||
{
|
|
||||||
logConfig->deconfigure();
|
|
||||||
delete logConfig;
|
|
||||||
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);
|
|
||||||
};
|
|
||||||
|
|
||||||
if(CSH->client && LOCPLINT && ask)
|
if(CSH->client && LOCPLINT && ask)
|
||||||
{
|
{
|
||||||
CCS->curh->changeGraphic(ECursor::ADVENTURE, 0);
|
CCS->curh->changeGraphic(ECursor::ADVENTURE, 0);
|
||||||
LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[69], quitApplication, nullptr);
|
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();
|
||||||
|
|
||||||
|
quitApplication();
|
||||||
|
}, nullptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user