mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-13 11:40:38 +02:00
Do not use std::atexit. Modified patch from PR #204 by @krnowak.
std::atexit generally does not play nice with static objects in other translation units/libraries - there are no guarantees about the order of destruction of static objects and atexit functions coming from different translation units/libraries. Removing calls to atexit fixes crashes when quitting the game. The crash happened during the dispose function somewhere inside boost's locale library that is used indirectly by the logger - some locale function tried to lock a static mutex that was already destroyed.
This commit is contained in:
parent
85f94676a5
commit
fb7ff8c7fa
@ -290,7 +290,6 @@ int main(int argc, char** argv)
|
||||
console = new CConsoleHandler;
|
||||
*console->cb = processCommand;
|
||||
console->start();
|
||||
atexit(dispose);
|
||||
|
||||
const bfs::path logPath = VCMIDirs::get().userCachePath() / "VCMI_Client_log.txt";
|
||||
CBasicLogConfigurator logConfig(logPath, console);
|
||||
@ -363,7 +362,6 @@ int main(int argc, char** argv)
|
||||
exit(-1);
|
||||
}
|
||||
GH.mainFPSmng->init(); //(!)init here AFTER SDL_Init() while using SDL for FPS management
|
||||
atexit(SDL_Quit);
|
||||
|
||||
SDL_LogSetOutputFunction(&SDLLogCallback, nullptr);
|
||||
|
||||
@ -1270,9 +1268,8 @@ void handleQuit(bool ask/* = true*/)
|
||||
{
|
||||
if(client)
|
||||
endGame();
|
||||
|
||||
delete console;
|
||||
console = nullptr;
|
||||
dispose();
|
||||
vstd::clear_pointer(console);
|
||||
boost::this_thread::sleep(boost::posix_time::milliseconds(750));
|
||||
if(!gNoGUI)
|
||||
SDL_Quit();
|
||||
|
Loading…
x
Reference in New Issue
Block a user