|
|
@@ -582,13 +582,13 @@ void printInfoAboutIntObject(const CIntObject *obj, int level)
|
|
|
void removeGUI()
|
|
|
{
|
|
|
// CClient::endGame
|
|
|
- GH.curInt = nullptr;
|
|
|
- if(GH.topInt())
|
|
|
- GH.topInt()->deactivate();
|
|
|
- adventureInt = nullptr;
|
|
|
- GH.listInt.clear();
|
|
|
- GH.objsToBlit.clear();
|
|
|
- GH.statusbar = nullptr;
|
|
|
+ GH.curInt = nullptr;
|
|
|
+ if(GH.topInt())
|
|
|
+ GH.topInt()->deactivate();
|
|
|
+ adventureInt = nullptr;
|
|
|
+ GH.listInt.clear();
|
|
|
+ GH.objsToBlit.clear();
|
|
|
+ GH.statusbar = nullptr;
|
|
|
logGlobal->info("Removed GUI.");
|
|
|
|
|
|
LOCPLINT = nullptr;
|
|
|
@@ -1508,88 +1508,89 @@ static void mainLoop()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-void handleQuit(bool ask)
|
|
|
+static void quitApplication()
|
|
|
{
|
|
|
- auto quitApplication = []()
|
|
|
+ if(!settings["session"]["headless"].Bool())
|
|
|
{
|
|
|
- if(!settings["session"]["headless"].Bool())
|
|
|
- {
|
|
|
- if(CSH->client)
|
|
|
- CSH->endGameplay();
|
|
|
- }
|
|
|
+ if(CSH->client)
|
|
|
+ CSH->endGameplay();
|
|
|
+ }
|
|
|
|
|
|
- GH.listInt.clear();
|
|
|
- GH.objsToBlit.clear();
|
|
|
+ GH.listInt.clear();
|
|
|
+ GH.objsToBlit.clear();
|
|
|
|
|
|
- CMM.reset();
|
|
|
+ CMM.reset();
|
|
|
|
|
|
- if(!settings["session"]["headless"].Bool())
|
|
|
+ if(!settings["session"]["headless"].Bool())
|
|
|
+ {
|
|
|
+ // cleanup, mostly to remove false leaks from analyzer
|
|
|
+ if(CCS)
|
|
|
{
|
|
|
- // cleanup, mostly to remove false leaks from analyzer
|
|
|
- if(CCS)
|
|
|
- {
|
|
|
- CCS->musich->release();
|
|
|
- CCS->soundh->release();
|
|
|
+ CCS->musich->release();
|
|
|
+ CCS->soundh->release();
|
|
|
|
|
|
- vstd::clear_pointer(CCS);
|
|
|
- }
|
|
|
- CMessage::dispose();
|
|
|
+ vstd::clear_pointer(CCS);
|
|
|
+ }
|
|
|
+ CMessage::dispose();
|
|
|
+
|
|
|
+ vstd::clear_pointer(graphics);
|
|
|
+ }
|
|
|
|
|
|
- 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();
|
|
|
}
|
|
|
|
|
|
- vstd::clear_pointer(VLC);
|
|
|
+ cleanupRenderer();
|
|
|
|
|
|
- vstd::clear_pointer(console);// should be removed after everything else since used by logging
|
|
|
+ if(nullptr != mainRenderer)
|
|
|
+ {
|
|
|
+ SDL_DestroyRenderer(mainRenderer);
|
|
|
+ mainRenderer = nullptr;
|
|
|
+ }
|
|
|
|
|
|
- boost::this_thread::sleep(boost::posix_time::milliseconds(750));//???
|
|
|
- if(!settings["session"]["headless"].Bool())
|
|
|
+ if(nullptr != mainWindow)
|
|
|
{
|
|
|
- if(settings["general"]["notifications"].Bool())
|
|
|
- {
|
|
|
- NotificationHandler::destroy();
|
|
|
- }
|
|
|
+ SDL_DestroyWindow(mainWindow);
|
|
|
+ mainWindow = nullptr;
|
|
|
+ }
|
|
|
|
|
|
- cleanupRenderer();
|
|
|
+ SDL_Quit();
|
|
|
+ }
|
|
|
|
|
|
- if(nullptr != mainRenderer)
|
|
|
- {
|
|
|
- SDL_DestroyRenderer(mainRenderer);
|
|
|
- mainRenderer = nullptr;
|
|
|
- }
|
|
|
+ if(logConfig != nullptr)
|
|
|
+ {
|
|
|
+ logConfig->deconfigure();
|
|
|
+ delete logConfig;
|
|
|
+ logConfig = nullptr;
|
|
|
+ }
|
|
|
|
|
|
- if(nullptr != mainWindow)
|
|
|
- {
|
|
|
- SDL_DestroyWindow(mainWindow);
|
|
|
- mainWindow = nullptr;
|
|
|
- }
|
|
|
+ std::cout << "Ending...\n";
|
|
|
+ exit(0);
|
|
|
+}
|
|
|
|
|
|
- SDL_Quit();
|
|
|
- }
|
|
|
+void handleQuit(bool ask)
|
|
|
+{
|
|
|
|
|
|
- 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)
|
|
|
{
|
|
|
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
|
|
|
{
|