mirror of
https://github.com/glest/glest-source.git
synced 2025-08-20 07:01:21 +02:00
- bugfix for proper thread shutdown which caused a number of crashes when navigating menus
This commit is contained in:
@@ -26,7 +26,7 @@ using namespace Shared::Platform;
|
||||
namespace Glest{ namespace Game{
|
||||
|
||||
const string mailString= "contact_game@glest.org";
|
||||
const string glestVersionString= "v3.3.5-beta7.3";
|
||||
const string glestVersionString= "v3.3.5-beta7.4";
|
||||
|
||||
string getCrashDumpFileName(){
|
||||
return "glest" + glestVersionString + ".dmp";
|
||||
|
@@ -326,11 +326,6 @@ MenuStateCustomGame::~MenuStateCustomGame() {
|
||||
needToRepublishToMasterserver = false;
|
||||
|
||||
BaseThread::shutdownAndWait(publishToMasterserverThread);
|
||||
safeMutex.ReleaseLock(true);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
safeMutex.Lock();
|
||||
delete publishToMasterserverThread;
|
||||
publishToMasterserverThread = NULL;
|
||||
safeMutex.ReleaseLock();
|
||||
@@ -346,6 +341,8 @@ void MenuStateCustomGame::returnToParentMenu(){
|
||||
needToRepublishToMasterserver = false;
|
||||
|
||||
BaseThread::shutdownAndWait(publishToMasterserverThread);
|
||||
delete publishToMasterserverThread;
|
||||
publishToMasterserverThread = NULL;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
@@ -389,6 +386,8 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
needToBroadcastServerSettings = false;
|
||||
needToRepublishToMasterserver = false;
|
||||
BaseThread::shutdownAndWait(publishToMasterserverThread);
|
||||
delete publishToMasterserverThread;
|
||||
publishToMasterserverThread = NULL;
|
||||
|
||||
safeMutex.ReleaseLock();
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
@@ -442,9 +441,6 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
needToRepublishToMasterserver = false;
|
||||
|
||||
BaseThread::shutdownAndWait(publishToMasterserverThread);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
delete publishToMasterserverThread;
|
||||
publishToMasterserverThread = NULL;
|
||||
safeMutex.ReleaseLock();
|
||||
|
@@ -132,6 +132,8 @@ void ServerLine::render(){
|
||||
MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMenu):
|
||||
MenuState(program, mainMenu, "masterserver")
|
||||
{
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
||||
autoRefreshTime=0;
|
||||
@@ -169,6 +171,8 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
||||
listBoxAutoRefresh.pushBackItem("30 s");
|
||||
listBoxAutoRefresh.setSelectedItemIndex(0);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
NetworkManager::getInstance().end();
|
||||
NetworkManager::getInstance().init(nrClient);
|
||||
//updateServerInfo();
|
||||
@@ -176,17 +180,25 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen
|
||||
needUpdateFromServer = true;
|
||||
updateFromMasterserverThread = new SimpleTaskThread(this,0,100);
|
||||
updateFromMasterserverThread->start();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
MenuStateMasterserver::~MenuStateMasterserver() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||
needUpdateFromServer = false;
|
||||
clearServerLines();
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
BaseThread::shutdownAndWait(updateFromMasterserverThread);
|
||||
delete updateFromMasterserverThread;
|
||||
updateFromMasterserverThread = NULL;
|
||||
|
||||
safeMutex.ReleaseLock();
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void MenuStateMasterserver::clearServerLines(){
|
||||
@@ -197,6 +209,7 @@ void MenuStateMasterserver::clearServerLines(){
|
||||
}
|
||||
|
||||
void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
CoreData &coreData= CoreData::getInstance();
|
||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||
@@ -213,27 +226,49 @@ void MenuStateMasterserver::mouseClick(int x, int y, MouseButton mouseButton){
|
||||
}
|
||||
}
|
||||
else if(buttonRefresh.mouseClick(x, y)){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||
soundRenderer.playFx(coreData.getClickSoundB());
|
||||
//updateServerInfo();
|
||||
needUpdateFromServer = true;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
else if(buttonReturn.mouseClick(x, y)){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||
soundRenderer.playFx(coreData.getClickSoundB());
|
||||
|
||||
BaseThread::shutdownAndWait(updateFromMasterserverThread);
|
||||
delete updateFromMasterserverThread;
|
||||
updateFromMasterserverThread = NULL;
|
||||
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
mainMenu->setState(new MenuStateRoot(program, mainMenu));
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
else if(buttonCreateGame.mouseClick(x, y)){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||
soundRenderer.playFx(coreData.getClickSoundB());
|
||||
|
||||
needUpdateFromServer = false;
|
||||
BaseThread::shutdownAndWait(updateFromMasterserverThread);
|
||||
delete updateFromMasterserverThread;
|
||||
updateFromMasterserverThread = NULL;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
mainMenu->setState(new MenuStateCustomGame(program, mainMenu,true,true));
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
else if(listBoxAutoRefresh.mouseClick(x, y)){
|
||||
MutexSafeWrapper safeMutex(&masterServerThreadAccessor);
|
||||
@@ -426,7 +461,8 @@ void MenuStateMasterserver::connectToServer(string ipString)
|
||||
//config.save();
|
||||
|
||||
BaseThread::shutdownAndWait(updateFromMasterserverThread);
|
||||
|
||||
delete updateFromMasterserverThread;
|
||||
updateFromMasterserverThread = NULL;
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
mainMenu->setState(new MenuStateConnectedGame(program, mainMenu,jmMasterserver));
|
||||
|
@@ -508,27 +508,12 @@ void ConnectionSlot::update(bool checkForNewClients) {
|
||||
void ConnectionSlot::close() {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s LINE: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
// In case we are closing from within the context of the thread
|
||||
// only signal it to quit here
|
||||
//if(slotThreadWorker != NULL) {
|
||||
// slotThreadWorker->signalQuit();
|
||||
//}
|
||||
//BaseThread::shutdownAndWait(slotThreadWorker);
|
||||
//delete slotThreadWorker;
|
||||
//slotThreadWorker = NULL;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s LINE: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
bool updateServerListener = (socket != NULL);
|
||||
delete socket;
|
||||
socket= NULL;
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s LINE: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//chatText.clear();
|
||||
//chatSender.clear();
|
||||
//chatTeamIndex= -1;
|
||||
|
||||
if(updateServerListener == true && ready == false) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s LINE: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
serverInterface->updateListen();
|
||||
|
@@ -36,7 +36,7 @@ protected:
|
||||
|
||||
public:
|
||||
BaseThread();
|
||||
~BaseThread();
|
||||
virtual ~BaseThread();
|
||||
virtual void execute()=0;
|
||||
|
||||
virtual void signalQuit();
|
||||
|
Reference in New Issue
Block a user