Browse Source

CGuiHandler: make terminate_cond non-static

Static variable might be not yet initialized by the time it's used inside CGuiHandler constructor.
This fix let us avoid crash that occur when built with Xcode 8.2.1
Arseniy Shestakov 8 năm trước cách đây
mục cha
commit
cd98dd0b89

+ 0 - 0
CMakeLists.txt.autosave.t10925


+ 0 - 0
CMakeLists.txt.s10925


+ 2 - 2
client/CPlayerInterface.cpp

@@ -125,7 +125,7 @@ CPlayerInterface::CPlayerInterface(PlayerColor Player)
 	makingTurn = false;
 	showingDialog = new CondSh<bool>(false);
 	cingconsole = new CInGameConsole();
-	GH.terminate_cond.set(false);
+	GH.terminate_cond->set(false);
 	firstCall = 1; //if loading will be overwritten in serialize
 	autosaveCount = 0;
 	isAutoFightOn = false;
@@ -2196,7 +2196,7 @@ void CPlayerInterface::gameOver(PlayerColor player, const EVictoryLossCheckResul
 		{
 			if (adventureInt)
 			{
-				GH.terminate_cond.setn(true);
+				GH.terminate_cond->setn(true);
 				adventureInt->deactivate();
 				if (GH.topInt() == adventureInt)
 					GH.popInt(adventureInt);

+ 1 - 1
client/CPreGame.cpp

@@ -546,7 +546,7 @@ CGPreGame *CGPreGame::create()
 	if(!CGP)
 		CGP = new CGPreGame();
 
-	GH.terminate_cond.set(false);
+	GH.terminate_cond->set(false);
 	return CGP;
 }
 

+ 2 - 3
client/gui/CGuiHandler.cpp

@@ -26,7 +26,6 @@
 extern std::queue<SDL_Event> events;
 extern boost::mutex eventsM;
 
-CondSh<bool> CGuiHandler::terminate_cond(false);
 boost::thread_specific_ptr<bool> inGuiThread;
 
 SObjectConstruction::SObjectConstruction(CIntObject *obj)
@@ -443,7 +442,7 @@ void CGuiHandler::renderFrame()
 	//in PreGame terminate_cond stay false
 
 	bool acquiredTheLockOnPim = false; //for tracking whether pim mutex locking succeeded
-	while(!terminate_cond.get() && !(acquiredTheLockOnPim = CPlayerInterface::pim->try_lock())) //try acquiring long until it succeeds or we are told to terminate
+	while(!terminate_cond->get() && !(acquiredTheLockOnPim = CPlayerInterface::pim->try_lock())) //try acquiring long until it succeeds or we are told to terminate
 		boost::this_thread::sleep(boost::posix_time::milliseconds(15));
 
 	if(acquiredTheLockOnPim)
@@ -481,7 +480,7 @@ CGuiHandler::CGuiHandler()
 	mainFPSmng = new CFramerateManager(48);
 	//do not init CFramerateManager here --AVS
 
-	terminate_cond.set(false);
+	terminate_cond = new CondSh<bool>(false);
 }
 
 CGuiHandler::~CGuiHandler()

+ 1 - 1
client/gui/CGuiHandler.h

@@ -113,7 +113,7 @@ public:
 	static bool amIGuiThread();
 	static void pushSDLEvent(int type, int usercode = 0);
 
-	static CondSh<bool> terminate_cond; // confirm termination
+	CondSh<bool> * terminate_cond; // confirm termination
 };
 
 extern CGuiHandler GH; //global gui handler