- better stability of menu navigation and threads
This commit is contained in:
parent
8c115809ce
commit
1e0a5dc304
|
@ -520,24 +520,31 @@ MenuStateCustomGame::~MenuStateCustomGame() {
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(publishToMasterserverThreadInDeletion == false) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
MutexSafeWrapper safeMutexPtr(&publishToMasterserverThreadPtrChangeAccessor);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(publishToMasterserverThread != NULL) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
needToBroadcastServerSettings = false;
|
||||
needToRepublishToMasterserver = false;
|
||||
|
||||
//BaseThread::shutdownAndWait(publishToMasterserverThread);
|
||||
if(publishToMasterserverThread != NULL &&
|
||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
delete publishToMasterserverThread;
|
||||
publishToMasterserverThread = NULL;
|
||||
}
|
||||
publishToMasterserverThread = NULL;
|
||||
|
||||
publishToMasterserverThreadInDeletion = false;
|
||||
safeMutexPtr.ReleaseLock();
|
||||
}
|
||||
else {
|
||||
safeMutexPtr.ReleaseLock();
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -562,8 +569,9 @@ void MenuStateCustomGame::returnToParentMenu(){
|
|||
if(publishToMasterserverThread != NULL &&
|
||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||
delete publishToMasterserverThread;
|
||||
publishToMasterserverThread = NULL;
|
||||
}
|
||||
publishToMasterserverThread = NULL;
|
||||
|
||||
publishToMasterserverThreadInDeletion = false;
|
||||
safeMutexPtr.ReleaseLock();
|
||||
|
||||
|
@ -614,8 +622,9 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
if(publishToMasterserverThread != NULL &&
|
||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||
delete publishToMasterserverThread;
|
||||
publishToMasterserverThread = NULL;
|
||||
}
|
||||
publishToMasterserverThread = NULL;
|
||||
|
||||
publishToMasterserverThreadInDeletion = false;
|
||||
safeMutexPtr.ReleaseLock();
|
||||
|
||||
|
@ -1127,8 +1136,9 @@ void MenuStateCustomGame::PlayNow() {
|
|||
if(publishToMasterserverThread != NULL &&
|
||||
publishToMasterserverThread->shutdownAndWait() == true) {
|
||||
delete publishToMasterserverThread;
|
||||
publishToMasterserverThread = NULL;
|
||||
}
|
||||
publishToMasterserverThread = NULL;
|
||||
|
||||
publishToMasterserverThreadInDeletion = false;
|
||||
safeMutexPtr.ReleaseLock();
|
||||
|
||||
|
@ -1877,6 +1887,11 @@ void MenuStateCustomGame::simpleTask() {
|
|||
bool needPing = (difftime(time(NULL),lastNetworkPing) >= GameConstants::networkPingInterval);
|
||||
safeMutex.ReleaseLock();
|
||||
|
||||
if( publishToMasterserverThread == NULL ||
|
||||
publishToMasterserverThread->getQuitStatus() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(republish == true) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -1911,6 +1926,11 @@ void MenuStateCustomGame::simpleTask() {
|
|||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if( publishToMasterserverThread == NULL ||
|
||||
publishToMasterserverThread->getQuitStatus() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(broadCastSettings) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
|
@ -1938,6 +1958,11 @@ void MenuStateCustomGame::simpleTask() {
|
|||
}
|
||||
}
|
||||
|
||||
if( publishToMasterserverThread == NULL ||
|
||||
publishToMasterserverThread->getQuitStatus() == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(needPing == true) {
|
||||
lastNetworkPing = time(NULL);
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ bool BaseThread::shutdownAndWait() {
|
|||
|
||||
int maxWaitSeconds = 7;
|
||||
if(pThread->canShutdown() == false) {
|
||||
maxWaitSeconds = 3;
|
||||
maxWaitSeconds = 2;
|
||||
}
|
||||
|
||||
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= maxWaitSeconds; ) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user