mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +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:
@@ -290,7 +290,6 @@ int main(int argc, char** argv)
|
|||||||
console = new CConsoleHandler;
|
console = new CConsoleHandler;
|
||||||
*console->cb = processCommand;
|
*console->cb = processCommand;
|
||||||
console->start();
|
console->start();
|
||||||
atexit(dispose);
|
|
||||||
|
|
||||||
const bfs::path logPath = VCMIDirs::get().userCachePath() / "VCMI_Client_log.txt";
|
const bfs::path logPath = VCMIDirs::get().userCachePath() / "VCMI_Client_log.txt";
|
||||||
CBasicLogConfigurator logConfig(logPath, console);
|
CBasicLogConfigurator logConfig(logPath, console);
|
||||||
@@ -363,7 +362,6 @@ int main(int argc, char** argv)
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
GH.mainFPSmng->init(); //(!)init here AFTER SDL_Init() while using SDL for FPS management
|
GH.mainFPSmng->init(); //(!)init here AFTER SDL_Init() while using SDL for FPS management
|
||||||
atexit(SDL_Quit);
|
|
||||||
|
|
||||||
SDL_LogSetOutputFunction(&SDLLogCallback, nullptr);
|
SDL_LogSetOutputFunction(&SDLLogCallback, nullptr);
|
||||||
|
|
||||||
@@ -1270,9 +1268,8 @@ void handleQuit(bool ask/* = true*/)
|
|||||||
{
|
{
|
||||||
if(client)
|
if(client)
|
||||||
endGame();
|
endGame();
|
||||||
|
dispose();
|
||||||
delete console;
|
vstd::clear_pointer(console);
|
||||||
console = nullptr;
|
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(750));
|
boost::this_thread::sleep(boost::posix_time::milliseconds(750));
|
||||||
if(!gNoGUI)
|
if(!gNoGUI)
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
|
Reference in New Issue
Block a user