瀏覽代碼

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 年之前
父節點
當前提交
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;
 	makingTurn = false;
 	showingDialog = new CondSh<bool>(false);
 	showingDialog = new CondSh<bool>(false);
 	cingconsole = new CInGameConsole();
 	cingconsole = new CInGameConsole();
-	GH.terminate_cond.set(false);
+	GH.terminate_cond->set(false);
 	firstCall = 1; //if loading will be overwritten in serialize
 	firstCall = 1; //if loading will be overwritten in serialize
 	autosaveCount = 0;
 	autosaveCount = 0;
 	isAutoFightOn = false;
 	isAutoFightOn = false;
@@ -2196,7 +2196,7 @@ void CPlayerInterface::gameOver(PlayerColor player, const EVictoryLossCheckResul
 		{
 		{
 			if (adventureInt)
 			if (adventureInt)
 			{
 			{
-				GH.terminate_cond.setn(true);
+				GH.terminate_cond->setn(true);
 				adventureInt->deactivate();
 				adventureInt->deactivate();
 				if (GH.topInt() == adventureInt)
 				if (GH.topInt() == adventureInt)
 					GH.popInt(adventureInt);
 					GH.popInt(adventureInt);

+ 1 - 1
client/CPreGame.cpp

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

+ 2 - 3
client/gui/CGuiHandler.cpp

@@ -26,7 +26,6 @@
 extern std::queue<SDL_Event> events;
 extern std::queue<SDL_Event> events;
 extern boost::mutex eventsM;
 extern boost::mutex eventsM;
 
 
-CondSh<bool> CGuiHandler::terminate_cond(false);
 boost::thread_specific_ptr<bool> inGuiThread;
 boost::thread_specific_ptr<bool> inGuiThread;
 
 
 SObjectConstruction::SObjectConstruction(CIntObject *obj)
 SObjectConstruction::SObjectConstruction(CIntObject *obj)
@@ -443,7 +442,7 @@ void CGuiHandler::renderFrame()
 	//in PreGame terminate_cond stay false
 	//in PreGame terminate_cond stay false
 
 
 	bool acquiredTheLockOnPim = false; //for tracking whether pim mutex locking succeeded
 	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));
 		boost::this_thread::sleep(boost::posix_time::milliseconds(15));
 
 
 	if(acquiredTheLockOnPim)
 	if(acquiredTheLockOnPim)
@@ -481,7 +480,7 @@ CGuiHandler::CGuiHandler()
 	mainFPSmng = new CFramerateManager(48);
 	mainFPSmng = new CFramerateManager(48);
 	//do not init CFramerateManager here --AVS
 	//do not init CFramerateManager here --AVS
 
 
-	terminate_cond.set(false);
+	terminate_cond = new CondSh<bool>(false);
 }
 }
 
 
 CGuiHandler::~CGuiHandler()
 CGuiHandler::~CGuiHandler()

+ 1 - 1
client/gui/CGuiHandler.h

@@ -113,7 +113,7 @@ public:
 	static bool amIGuiThread();
 	static bool amIGuiThread();
 	static void pushSDLEvent(int type, int usercode = 0);
 	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
 extern CGuiHandler GH; //global gui handler