mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Fix crash on closing vcmi while opening is playing
This commit is contained in:
@@ -55,12 +55,14 @@
|
||||
namespace po = boost::program_options;
|
||||
namespace po_style = boost::program_options::command_line_style;
|
||||
|
||||
static std::atomic<bool> quitRequestedDuringOpeningPlayback = false;
|
||||
static po::variables_map vm;
|
||||
|
||||
#ifndef VCMI_IOS
|
||||
void processCommand(const std::string &message);
|
||||
#endif
|
||||
void playIntro();
|
||||
[[noreturn]] static void quitApplication();
|
||||
static void mainLoop();
|
||||
|
||||
static CBasicLogConfigurator *logConfig;
|
||||
@@ -313,7 +315,6 @@ int main(int argc, char * argv[])
|
||||
GH.screenHandler().clearScreen();
|
||||
}
|
||||
|
||||
|
||||
#ifndef VCMI_NO_THREADED_LOAD
|
||||
#ifdef VCMI_ANDROID // android loads the data quite slowly so we display native progressbar to prevent having only black screen for few seconds
|
||||
{
|
||||
@@ -327,6 +328,9 @@ int main(int argc, char * argv[])
|
||||
#endif // ANDROID
|
||||
#endif // THREADED
|
||||
|
||||
if (quitRequestedDuringOpeningPlayback)
|
||||
quitApplication();
|
||||
|
||||
if(!settings["session"]["headless"].Bool())
|
||||
{
|
||||
pomtime.getDiff();
|
||||
@@ -451,7 +455,7 @@ static void mainLoop()
|
||||
}
|
||||
}
|
||||
|
||||
static void quitApplication()
|
||||
[[noreturn]] static void quitApplication()
|
||||
{
|
||||
if(!settings["session"]["headless"].Bool())
|
||||
{
|
||||
@@ -516,6 +520,15 @@ static void quitApplication()
|
||||
|
||||
void handleQuit(bool ask)
|
||||
{
|
||||
// FIXME: avoids crash if player attempts to close game while opening is still playing
|
||||
// use cursor handler as indicator that loading is not done yet
|
||||
// proper solution would be to abort init thread (or wait for it to finish)
|
||||
if (!CCS->curh)
|
||||
{
|
||||
quitRequestedDuringOpeningPlayback = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if(ask)
|
||||
{
|
||||
CCS->curh->set(Cursor::Map::POINTER);
|
||||
|
Reference in New Issue
Block a user