mirror of
https://github.com/glest/glest-source.git
synced 2025-08-11 19:04:00 +02:00
bugfix for shutdown of threads and garbage collection.
This commit is contained in:
@@ -149,7 +149,7 @@ public:
|
|||||||
|
|
||||||
void cleanupCRCThread() {
|
void cleanupCRCThread() {
|
||||||
if(preCacheThread != NULL) {
|
if(preCacheThread != NULL) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
const double MAX_THREAD_WAIT = 60;
|
const double MAX_THREAD_WAIT = 60;
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("START - shutting down crc threads\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("START - shutting down crc threads\n");
|
||||||
@@ -170,13 +170,13 @@ void cleanupCRCThread() {
|
|||||||
preCacheThread=NULL;
|
preCacheThread=NULL;
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("C - shutting down crc threads\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("C - shutting down crc threads\n");
|
||||||
}
|
}
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("D - shutting down crc threads\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("D - shutting down crc threads\n");
|
||||||
|
|
||||||
if(preCacheThread->canShutdown(false) == true) {
|
if(preCacheThread->canShutdown(false) == true) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
delete preCacheThread;
|
delete preCacheThread;
|
||||||
preCacheThread=NULL;
|
preCacheThread=NULL;
|
||||||
|
|
||||||
@@ -186,13 +186,13 @@ void cleanupCRCThread() {
|
|||||||
}
|
}
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("F - shutting down crc threads\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("F - shutting down crc threads\n");
|
||||||
preCacheThread = NULL;
|
preCacheThread = NULL;
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cleanupProcessObjects() {
|
static void cleanupProcessObjects() {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||||
showCursor(true);
|
showCursor(true);
|
||||||
@@ -232,8 +232,8 @@ static void cleanupProcessObjects() {
|
|||||||
//printf("Closing IRC CLient %d\n",__LINE__);
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
|
|
||||||
cleanupCRCThread();
|
cleanupCRCThread();
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//printf("Closing IRC CLient %d\n",__LINE__);
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
if(Renderer::isEnded() == false) {
|
if(Renderer::isEnded() == false) {
|
||||||
@@ -244,7 +244,7 @@ static void cleanupProcessObjects() {
|
|||||||
|
|
||||||
//printf("Closing IRC CLient %d\n",__LINE__);
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
SystemFlags::Close();
|
SystemFlags::Close();
|
||||||
SystemFlags::SHUTDOWN_PROGRAM_MODE=true;
|
SystemFlags::SHUTDOWN_PROGRAM_MODE=true;
|
||||||
@@ -296,7 +296,7 @@ static void cleanupProcessObjects() {
|
|||||||
|
|
||||||
//printf("Closing IRC CLient %d\n",__LINE__);
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
|
||||||
SystemFlags::globalCleanupHTTP();
|
SystemFlags::globalCleanupHTTP();
|
||||||
@@ -625,7 +625,7 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ExceptionHandler::handleRuntimeError(const char *msg, bool getStackTraceString) {
|
void ExceptionHandler::handleRuntimeError(const char *msg, bool getStackTraceString) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
static bool inErrorNow = false;
|
static bool inErrorNow = false;
|
||||||
if(inErrorNow == true) {
|
if(inErrorNow == true) {
|
||||||
@@ -639,13 +639,13 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) {
|
|||||||
|
|
||||||
logError(msg,true);
|
logError(msg,true);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] program = %p gameInitialized = %d msg [%s]\n",__FILE__,__FUNCTION__,__LINE__,mainProgram,gameInitialized,msg);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] program = %p gameInitialized = %d msg [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,mainProgram,gameInitialized,msg);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] [%s] gameInitialized = %d, program = %p\n",__FILE__,__FUNCTION__,__LINE__,msg,gameInitialized,mainProgram);
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] [%s] gameInitialized = %d, program = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg,gameInitialized,mainProgram);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%s] gameInitialized = %d, program = %p\n",__FILE__,__FUNCTION__,__LINE__,msg,gameInitialized,mainProgram);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%s] gameInitialized = %d, program = %p\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg,gameInitialized,mainProgram);
|
||||||
|
|
||||||
string errMsg = (msg != NULL ? msg : "null");
|
string errMsg = (msg != NULL ? msg : "null");
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
bool gotStackTrace = false;
|
bool gotStackTrace = false;
|
||||||
if(getStackTraceString == true && disableBacktrace == false && sdl_quitCalled == false) {
|
if(getStackTraceString == true && disableBacktrace == false && sdl_quitCalled == false) {
|
||||||
@@ -654,27 +654,27 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) {
|
|||||||
gotStackTrace = true;
|
gotStackTrace = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
logError(errMsg.c_str(),false);
|
logError(errMsg.c_str(),false);
|
||||||
|
|
||||||
if(gotStackTrace == true) {
|
if(gotStackTrace == true) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] [%s]\n",__FILE__,__FUNCTION__,__LINE__,errMsg.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,errMsg.c_str());
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%s]\n",__FILE__,__FUNCTION__,__LINE__,errMsg.c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,errMsg.c_str());
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//abort();
|
//abort();
|
||||||
|
|
||||||
if(mainProgram && gameInitialized == true) {
|
if(mainProgram && gameInitialized == true) {
|
||||||
//printf("\nprogram->getState() [%p]\n",program->getState());
|
//printf("\nprogram->getState() [%p]\n",program->getState());
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(mainProgram->getState() != NULL) {
|
if(mainProgram->getState() != NULL) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
mainProgram->showMessage(errMsg.c_str());
|
mainProgram->showMessage(errMsg.c_str());
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(glActiveTexture != NULL) {
|
if(glActiveTexture != NULL) {
|
||||||
for(;GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && mainProgram->isMessageShowing();) {
|
for(;GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && mainProgram->isMessageShowing();) {
|
||||||
@@ -694,9 +694,9 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
mainProgram->showMessage(errMsg.c_str());
|
mainProgram->showMessage(errMsg.c_str());
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(glActiveTexture != NULL) {
|
if(glActiveTexture != NULL) {
|
||||||
for(;GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && mainProgram->isMessageShowing();) {
|
for(;GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && mainProgram->isMessageShowing();) {
|
||||||
@@ -715,10 +715,10 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
string err = "#2 An error occurred and ";
|
string err = "#2 An error occurred and ";
|
||||||
if(sdl_quitCalled == false) {
|
if(sdl_quitCalled == false) {
|
||||||
@@ -731,19 +731,19 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) {
|
|||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
err += string(", attaching the generated ") + getCrashDumpFileName() + string(" file.");
|
err += string(", attaching the generated ") + getCrashDumpFileName() + string(" file.");
|
||||||
#endif
|
#endif
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
message(err);
|
message(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
// Now try to shutdown threads if possible
|
// Now try to shutdown threads if possible
|
||||||
delete mainProgram;
|
delete mainProgram;
|
||||||
mainProgram = NULL;
|
mainProgram = NULL;
|
||||||
// END
|
// END
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
||||||
@@ -756,20 +756,20 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) {
|
|||||||
inErrorNow = false;
|
inErrorNow = false;
|
||||||
throw runtimeErrorMsg;
|
throw runtimeErrorMsg;
|
||||||
#endif
|
#endif
|
||||||
//printf("In [%s::%s Line: %d] [%s] gameInitialized = %d\n",__FILE__,__FUNCTION__,__LINE__,msg,gameInitialized);
|
//printf("In [%s::%s Line: %d] [%s] gameInitialized = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg,gameInitialized);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
cleanupProcessObjects();
|
cleanupProcessObjects();
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(sdl_quitCalled == false) {
|
if(sdl_quitCalled == false) {
|
||||||
sdl_quitCalled = true;
|
sdl_quitCalled = true;
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
inErrorNow = false;
|
inErrorNow = false;
|
||||||
|
|
||||||
@@ -777,22 +777,22 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ExceptionHandler::DisplayMessage(const char *msg, bool exitApp) {
|
int ExceptionHandler::DisplayMessage(const char *msg, bool exitApp) {
|
||||||
//printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",__FILE__,__FUNCTION__,__LINE__,msg,exitApp);
|
//printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg,exitApp);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",__FILE__,__FUNCTION__,__LINE__,msg,exitApp);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg,exitApp);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] msg [%s] exitApp = %d\n",__FILE__,__FUNCTION__,__LINE__,msg,exitApp);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] msg [%s] exitApp = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg,exitApp);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",__FILE__,__FUNCTION__,__LINE__,msg,exitApp);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg,exitApp);
|
||||||
|
|
||||||
if(mainProgram && gameInitialized == true) {
|
if(mainProgram && gameInitialized == true) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",__FILE__,__FUNCTION__,__LINE__,msg,exitApp);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg,exitApp);
|
||||||
mainProgram->showMessage(msg);
|
mainProgram->showMessage(msg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",__FILE__,__FUNCTION__,__LINE__,msg,exitApp);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg,exitApp);
|
||||||
message(msg);
|
message(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",__FILE__,__FUNCTION__,__LINE__,msg,exitApp);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg,exitApp);
|
||||||
|
|
||||||
if(exitApp == true) {
|
if(exitApp == true) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",msg);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s\n",msg);
|
||||||
@@ -802,7 +802,7 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) {
|
|||||||
mainProgram = NULL;
|
mainProgram = NULL;
|
||||||
// END
|
// END
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",__FILE__,__FUNCTION__,__LINE__,msg,exitApp);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg,exitApp);
|
||||||
cleanupProcessObjects();
|
cleanupProcessObjects();
|
||||||
|
|
||||||
if(sdl_quitCalled == false) {
|
if(sdl_quitCalled == false) {
|
||||||
@@ -812,7 +812,7 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) {
|
|||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",__FILE__,__FUNCTION__,__LINE__,msg,exitApp);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] msg [%s] exitApp = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg,exitApp);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -830,10 +830,10 @@ MainWindow::MainWindow(Program *program) : WindowGl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow(){
|
MainWindow::~MainWindow(){
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
delete program;
|
delete program;
|
||||||
program = NULL;
|
program = NULL;
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::eventMouseDown(int x, int y, MouseButton mouseButton){
|
void MainWindow::eventMouseDown(int x, int y, MouseButton mouseButton){
|
||||||
@@ -864,7 +864,7 @@ void MainWindow::eventMouseDown(int x, int y, MouseButton mouseButton){
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
switch(mouseButton) {
|
switch(mouseButton) {
|
||||||
case mbLeft:
|
case mbLeft:
|
||||||
@@ -880,7 +880,7 @@ void MainWindow::eventMouseDown(int x, int y, MouseButton mouseButton){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
ProgramState *programState = program->getState();
|
ProgramState *programState = program->getState();
|
||||||
if(programState != NULL) {
|
if(programState != NULL) {
|
||||||
@@ -897,13 +897,13 @@ void MainWindow::eventMouseDown(int x, int y, MouseButton mouseButton){
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::eventMouseUp(int x, int y, MouseButton mouseButton){
|
void MainWindow::eventMouseUp(int x, int y, MouseButton mouseButton){
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
const Metrics &metrics = Metrics::getInstance();
|
const Metrics &metrics = Metrics::getInstance();
|
||||||
int vx = metrics.toVirtualX(x);
|
int vx = metrics.toVirtualX(x);
|
||||||
@@ -913,14 +913,14 @@ void MainWindow::eventMouseUp(int x, int y, MouseButton mouseButton){
|
|||||||
throw megaglest_runtime_error("In [MainWindow::eventMouseUp] ERROR, program == NULL!");
|
throw megaglest_runtime_error("In [MainWindow::eventMouseUp] ERROR, program == NULL!");
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
ProgramState *programState = program->getState();
|
ProgramState *programState = program->getState();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(programState != NULL) {
|
if(programState != NULL) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
switch(mouseButton) {
|
switch(mouseButton) {
|
||||||
case mbLeft:
|
case mbLeft:
|
||||||
@@ -935,13 +935,13 @@ void MainWindow::eventMouseUp(int x, int y, MouseButton mouseButton){
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::eventMouseDoubleClick(int x, int y, MouseButton mouseButton) {
|
void MainWindow::eventMouseDoubleClick(int x, int y, MouseButton mouseButton) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
int vx = metrics.toVirtualX(x);
|
int vx = metrics.toVirtualX(x);
|
||||||
@@ -951,14 +951,14 @@ void MainWindow::eventMouseDoubleClick(int x, int y, MouseButton mouseButton) {
|
|||||||
throw megaglest_runtime_error("In [MainWindow::eventMouseDoubleClick] ERROR, program == NULL!");
|
throw megaglest_runtime_error("In [MainWindow::eventMouseDoubleClick] ERROR, program == NULL!");
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
ProgramState *programState = program->getState();
|
ProgramState *programState = program->getState();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(programState != NULL) {
|
if(programState != NULL) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
switch(mouseButton){
|
switch(mouseButton){
|
||||||
case mbLeft:
|
case mbLeft:
|
||||||
@@ -974,9 +974,9 @@ void MainWindow::eventMouseDoubleClick(int x, int y, MouseButton mouseButton) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::eventMouseMove(int x, int y, const MouseState *ms){
|
void MainWindow::eventMouseMove(int x, int y, const MouseState *ms){
|
||||||
@@ -999,7 +999,7 @@ void MainWindow::eventMouseMove(int x, int y, const MouseState *ms){
|
|||||||
|
|
||||||
void MainWindow::eventMouseWheel(int x, int y, int zDelta) {
|
void MainWindow::eventMouseWheel(int x, int y, int zDelta) {
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
const Metrics &metrics= Metrics::getInstance();
|
const Metrics &metrics= Metrics::getInstance();
|
||||||
int vx = metrics.toVirtualX(x);
|
int vx = metrics.toVirtualX(x);
|
||||||
@@ -1015,7 +1015,7 @@ void MainWindow::eventMouseWheel(int x, int y, int zDelta) {
|
|||||||
programState->eventMouseWheel(vx, vy, zDelta);
|
programState->eventMouseWheel(vx, vy, zDelta);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::render() {
|
void MainWindow::render() {
|
||||||
@@ -1115,13 +1115,13 @@ void MainWindow::toggleLanguage(string language) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::eventKeyDown(SDL_KeyboardEvent key) {
|
void MainWindow::eventKeyDown(SDL_KeyboardEvent key) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key.keysym.sym);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key.keysym.sym);
|
||||||
|
|
||||||
//SDL_keysym keystate = Window::getKeystate();
|
//SDL_keysym keystate = Window::getKeystate();
|
||||||
SDL_keysym keystate = key.keysym;
|
SDL_keysym keystate = key.keysym;
|
||||||
//printf("keystate.mod = %d key = %d lalt [%d] ralt [%d] alt [%d]\n",keystate.mod,key.keysym.unicode,(keystate.mod & KMOD_LALT),(keystate.mod & KMOD_RALT),(keystate.mod & KMOD_ALT));
|
//printf("keystate.mod = %d key = %d lalt [%d] ralt [%d] alt [%d]\n",keystate.mod,key.keysym.unicode,(keystate.mod & KMOD_LALT),(keystate.mod & KMOD_RALT),(keystate.mod & KMOD_ALT));
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c][%d]\n",__FILE__,__FUNCTION__,__LINE__,key,key);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = [%c][%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key,key);
|
||||||
|
|
||||||
if(program == NULL) {
|
if(program == NULL) {
|
||||||
throw megaglest_runtime_error("In [MainWindow::eventKeyDown] ERROR, program == NULL!");
|
throw megaglest_runtime_error("In [MainWindow::eventKeyDown] ERROR, program == NULL!");
|
||||||
@@ -1140,12 +1140,12 @@ void MainWindow::eventKeyDown(SDL_KeyboardEvent key) {
|
|||||||
|
|
||||||
program->keyDown(key);
|
program->keyDown(key);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(keystate.mod & (KMOD_LALT | KMOD_RALT)) {
|
if(keystate.mod & (KMOD_LALT | KMOD_RALT)) {
|
||||||
//if(key == vkReturn) {
|
//if(key == vkReturn) {
|
||||||
if(isKeyPressed(SDLK_RETURN,key) == true) {
|
if(isKeyPressed(SDLK_RETURN,key) == true) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ALT-ENTER pressed\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] ALT-ENTER pressed\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
// This stupidity only required in win32.
|
// This stupidity only required in win32.
|
||||||
// We reload the textures so that the canvas paints textures properly
|
// We reload the textures so that the canvas paints textures properly
|
||||||
@@ -1156,12 +1156,12 @@ void MainWindow::eventKeyDown(SDL_KeyboardEvent key) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(program != NULL && program->isInSpecialKeyCaptureEvent() == false) {
|
if(program != NULL && program->isInSpecialKeyCaptureEvent() == false) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
vector<int> modifiersToCheck;
|
vector<int> modifiersToCheck;
|
||||||
modifiersToCheck.push_back(KMOD_LCTRL);
|
modifiersToCheck.push_back(KMOD_LCTRL);
|
||||||
@@ -1244,7 +1244,7 @@ void MainWindow::eventKeyDown(SDL_KeyboardEvent key) {
|
|||||||
snprintf(szBuf,8096,"Screenshot will be saved to: %s",path.c_str());
|
snprintf(szBuf,8096,"Screenshot will be saved to: %s",path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,szBuf);
|
||||||
|
|
||||||
bool showScreenshotSavedMsg = Config::getInstance().getBool("DisableScreenshotConsoleText","false");
|
bool showScreenshotSavedMsg = Config::getInstance().getBool("DisableScreenshotConsoleText","false");
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Screenshot console showScreenshotSavedMsg = %d\n",showScreenshotSavedMsg);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Screenshot console showScreenshotSavedMsg = %d\n",showScreenshotSavedMsg);
|
||||||
@@ -1267,21 +1267,21 @@ void MainWindow::eventKeyDown(SDL_KeyboardEvent key) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::eventKeyUp(SDL_KeyboardEvent key) {
|
void MainWindow::eventKeyUp(SDL_KeyboardEvent key) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key);
|
||||||
if(program == NULL) {
|
if(program == NULL) {
|
||||||
throw megaglest_runtime_error("In [MainWindow::eventKeyUp] ERROR, program == NULL!");
|
throw megaglest_runtime_error("In [MainWindow::eventKeyUp] ERROR, program == NULL!");
|
||||||
}
|
}
|
||||||
|
|
||||||
program->keyUp(key);
|
program->keyUp(key);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,key);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::eventKeyPress(SDL_KeyboardEvent c) {
|
void MainWindow::eventKeyPress(SDL_KeyboardEvent c) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,c);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||||
if(program == NULL) {
|
if(program == NULL) {
|
||||||
throw megaglest_runtime_error("In [MainWindow::eventKeyPress] ERROR, program == NULL!");
|
throw megaglest_runtime_error("In [MainWindow::eventKeyPress] ERROR, program == NULL!");
|
||||||
}
|
}
|
||||||
@@ -1289,12 +1289,12 @@ void MainWindow::eventKeyPress(SDL_KeyboardEvent c) {
|
|||||||
program->keyPress(c);
|
program->keyPress(c);
|
||||||
|
|
||||||
if(program != NULL && program->isInSpecialKeyCaptureEvent() == false) {
|
if(program != NULL && program->isInSpecialKeyCaptureEvent() == false) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
Config &configKeys = Config::getInstance(std::pair<ConfigType,ConfigType>(cfgMainKeys,cfgUserKeys));
|
||||||
//if(c == configKeys.getCharKey("HotKeyToggleOSMouseEnabled")) {
|
//if(c == configKeys.getCharKey("HotKeyToggleOSMouseEnabled")) {
|
||||||
if(isKeyPressed(configKeys.getSDLKey("HotKeyToggleOSMouseEnabled"),c) == true) {
|
if(isKeyPressed(configKeys.getSDLKey("HotKeyToggleOSMouseEnabled"),c) == true) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
bool showCursorState = false;
|
bool showCursorState = false;
|
||||||
int state = SDL_ShowCursor(SDL_QUERY);
|
int state = SDL_ShowCursor(SDL_QUERY);
|
||||||
@@ -1307,10 +1307,10 @@ void MainWindow::eventKeyPress(SDL_KeyboardEvent c) {
|
|||||||
renderer.setNo2DMouseRendering(showCursorState);
|
renderer.setNo2DMouseRendering(showCursorState);
|
||||||
|
|
||||||
Window::lastShowMouseState = SDL_ShowCursor(SDL_QUERY);
|
Window::lastShowMouseState = SDL_ShowCursor(SDL_QUERY);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::lastShowMouseState = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::lastShowMouseState);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::lastShowMouseState = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::lastShowMouseState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",__FILE__,__FUNCTION__,__LINE__,c);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::eventActivate(bool active) {
|
void MainWindow::eventActivate(bool active) {
|
||||||
@@ -3447,7 +3447,10 @@ int glestMain(int argc, char** argv) {
|
|||||||
SystemFlags::VERBOSE_MODE_ENABLED = false;
|
SystemFlags::VERBOSE_MODE_ENABLED = false;
|
||||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VERBOSE_MODE]) == true) {
|
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VERBOSE_MODE]) == true) {
|
||||||
SystemFlags::VERBOSE_MODE_ENABLED = true;
|
SystemFlags::VERBOSE_MODE_ENABLED = true;
|
||||||
|
Thread::setEnableVerboseMode(true);
|
||||||
}
|
}
|
||||||
|
// DEbug testing threads
|
||||||
|
//Thread::setEnableVerboseMode(true);
|
||||||
|
|
||||||
if( hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_MASTERSERVER_MODE])) == true) {
|
if( hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_MASTERSERVER_MODE])) == true) {
|
||||||
//isMasterServerModeEnabled = true;
|
//isMasterServerModeEnabled = true;
|
||||||
@@ -4133,7 +4136,7 @@ int glestMain(int argc, char** argv) {
|
|||||||
// Setup debug logging etc
|
// Setup debug logging etc
|
||||||
setupLogging(config, haveSpecialOutputCommandLineOption);
|
setupLogging(config, haveSpecialOutputCommandLineOption);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Font::charCount = %d, Font::fontTypeName [%s] Shared::Platform::charSet = %d, Font::fontIsMultibyte = %d, fontIsRightToLeft = %d\n",__FILE__,__FUNCTION__,__LINE__,Shared::Graphics::Font::charCount,Shared::Graphics::Font::fontTypeName.c_str(),Shared::Platform::charSet,Shared::Graphics::Font::fontIsMultibyte, Shared::Graphics::Font::fontIsRightToLeft);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Font::charCount = %d, Font::fontTypeName [%s] Shared::Platform::charSet = %d, Font::fontIsMultibyte = %d, fontIsRightToLeft = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Shared::Graphics::Font::charCount,Shared::Graphics::Font::fontTypeName.c_str(),Shared::Platform::charSet,Shared::Graphics::Font::fontIsMultibyte, Shared::Graphics::Font::fontIsRightToLeft);
|
||||||
|
|
||||||
NetworkInterface::setDisplayMessageFunction(ExceptionHandler::DisplayMessage);
|
NetworkInterface::setDisplayMessageFunction(ExceptionHandler::DisplayMessage);
|
||||||
MenuStateMasterserver::setDisplayMessageFunction(ExceptionHandler::DisplayMessage);
|
MenuStateMasterserver::setDisplayMessageFunction(ExceptionHandler::DisplayMessage);
|
||||||
@@ -4144,7 +4147,7 @@ int glestMain(int argc, char** argv) {
|
|||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s, STREFLOP NOT enabled.\n",getNetworkVersionString().c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s, STREFLOP NOT enabled.\n",getNetworkVersionString().c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"START\n");
|
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"START\n");
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugPathFinder,"START\n");
|
SystemFlags::OutputDebug(SystemFlags::debugPathFinder,"START\n");
|
||||||
|
|
||||||
@@ -4154,7 +4157,7 @@ int glestMain(int argc, char** argv) {
|
|||||||
std::pair<string,string>(Config::glestkeys_ini_filename,Config::glestuserkeys_ini_filename),
|
std::pair<string,string>(Config::glestkeys_ini_filename,Config::glestuserkeys_ini_filename),
|
||||||
std::pair<bool,bool>(true,false));
|
std::pair<bool,bool>(true,false));
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SHOW_INI_SETTINGS]) == true) {
|
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SHOW_INI_SETTINGS]) == true) {
|
||||||
ShowINISettings(argc,argv,config,configKeys);
|
ShowINISettings(argc,argv,config,configKeys);
|
||||||
@@ -4307,7 +4310,7 @@ int glestMain(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Font::charCount = %d, Font::fontTypeName [%s] Shared::Platform::charSet = %d, Font::fontIsMultibyte = %d, Font::fontIsRightToLeft = %d\n",__FILE__,__FUNCTION__,__LINE__,Shared::Graphics::Font::charCount,Shared::Graphics::Font::fontTypeName.c_str(),Shared::Platform::charSet,Shared::Graphics::Font::fontIsMultibyte,Shared::Graphics::Font::fontIsRightToLeft);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Font::charCount = %d, Font::fontTypeName [%s] Shared::Platform::charSet = %d, Font::fontIsMultibyte = %d, Font::fontIsRightToLeft = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Shared::Graphics::Font::charCount,Shared::Graphics::Font::fontTypeName.c_str(),Shared::Platform::charSet,Shared::Graphics::Font::fontIsMultibyte,Shared::Graphics::Font::fontIsRightToLeft);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using Font::charCount = %d, Font::fontTypeName [%s] Shared::Platform::charSet = %d, Font::fontIsMultibyte = %d, Font::fontIsRightToLeft = %d\n",Shared::Graphics::Font::charCount,Shared::Graphics::Font::fontTypeName.c_str(),Shared::Platform::charSet,Shared::Graphics::Font::fontIsMultibyte,Shared::Graphics::Font::fontIsRightToLeft);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using Font::charCount = %d, Font::fontTypeName [%s] Shared::Platform::charSet = %d, Font::fontIsMultibyte = %d, Font::fontIsRightToLeft = %d\n",Shared::Graphics::Font::charCount,Shared::Graphics::Font::fontTypeName.c_str(),Shared::Platform::charSet,Shared::Graphics::Font::fontIsMultibyte,Shared::Graphics::Font::fontIsRightToLeft);
|
||||||
|
|
||||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_USE_FONT]) == true) {
|
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_USE_FONT]) == true) {
|
||||||
@@ -4339,7 +4342,7 @@ int glestMain(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SHOW_MAP_CRC]) == true) {
|
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SHOW_MAP_CRC]) == true) {
|
||||||
int foundParamIndIndex = -1;
|
int foundParamIndIndex = -1;
|
||||||
@@ -4787,7 +4790,7 @@ int glestMain(int argc, char** argv) {
|
|||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled == true) {
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled == true) {
|
||||||
renderer.setAllowRenderUnitTitles(SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled);
|
renderer.setAllowRenderUnitTitles(SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugPathFinder,"In [%s::%s Line: %d] renderer.setAllowRenderUnitTitles = %d\n",__FILE__,__FUNCTION__,__LINE__,SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled);
|
SystemFlags::OutputDebug(SystemFlags::debugPathFinder,"In [%s::%s Line: %d] renderer.setAllowRenderUnitTitles = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,SystemFlags::getSystemSettingType(SystemFlags::debugPathFinder).enabled);
|
||||||
}
|
}
|
||||||
renderer.setAllowRenderUnitTitles(true);
|
renderer.setAllowRenderUnitTitles(true);
|
||||||
|
|
||||||
@@ -4815,13 +4818,13 @@ int glestMain(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
// Cache Player textures - END
|
// Cache Player textures - END
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
mainWindow= new MainWindow(program);
|
mainWindow= new MainWindow(program);
|
||||||
|
|
||||||
mainWindow->setUseDefaultCursorOnly(config.getBool("No2DMouseRendering","false"));
|
mainWindow->setUseDefaultCursorOnly(config.getBool("No2DMouseRendering","false"));
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
GameSettings startupGameSettings;
|
GameSettings startupGameSettings;
|
||||||
|
|
||||||
@@ -5036,11 +5039,11 @@ int glestMain(int argc, char** argv) {
|
|||||||
program->initNormal(mainWindow);
|
program->initNormal(mainWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
// Initialize Renderer
|
// Initialize Renderer
|
||||||
//Renderer &renderer= Renderer::getInstance();
|
//Renderer &renderer= Renderer::getInstance();
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] OpenGL Info:\n%s\n",__FILE__,__FUNCTION__,__LINE__,renderer.getGlInfo().c_str());
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] OpenGL Info:\n%s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,renderer.getGlInfo().c_str());
|
||||||
|
|
||||||
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_OPENGL_INFO]) == true) {
|
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_OPENGL_INFO]) == true) {
|
||||||
//Renderer &renderer= Renderer::getInstance();
|
//Renderer &renderer= Renderer::getInstance();
|
||||||
@@ -5210,11 +5213,11 @@ int glestMain(int argc, char** argv) {
|
|||||||
// endPathWithSlash(userData);
|
// endPathWithSlash(userData);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
CheckForDuplicateData();
|
CheckForDuplicateData();
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//throw "BLAH!";
|
//throw "BLAH!";
|
||||||
|
|
||||||
@@ -5223,8 +5226,8 @@ int glestMain(int argc, char** argv) {
|
|||||||
//printf("%d\n", *foo); // causes segfault
|
//printf("%d\n", *foo); // causes segfault
|
||||||
// END
|
// END
|
||||||
bool startCRCPrecacheThread = config.getBool("PreCacheCRCThread","true");
|
bool startCRCPrecacheThread = config.getBool("PreCacheCRCThread","true");
|
||||||
//printf("### In [%s::%s Line: %d] precache thread enabled = %d SystemFlags::VERBOSE_MODE_ENABLED = %d\n",__FILE__,__FUNCTION__,__LINE__,startCRCPrecacheThread,SystemFlags::VERBOSE_MODE_ENABLED);
|
//printf("### In [%s::%s Line: %d] precache thread enabled = %d SystemFlags::VERBOSE_MODE_ENABLED = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,startCRCPrecacheThread,SystemFlags::VERBOSE_MODE_ENABLED);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] precache thread enabled = %d\n",__FILE__,__FUNCTION__,__LINE__,startCRCPrecacheThread);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] precache thread enabled = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,startCRCPrecacheThread);
|
||||||
if(startCRCPrecacheThread == true) {
|
if(startCRCPrecacheThread == true) {
|
||||||
vector<string> techDataPaths = config.getPathListForType(ptTechs);
|
vector<string> techDataPaths = config.getPathListForType(ptTechs);
|
||||||
static string mutexOwnerId = string(extractFileFromDirectoryPath(__FILE__).c_str()) + string("_") + intToStr(__LINE__);
|
static string mutexOwnerId = string(extractFileFromDirectoryPath(__FILE__).c_str()) + string("_") + intToStr(__LINE__);
|
||||||
@@ -5277,6 +5280,8 @@ int glestMain(int argc, char** argv) {
|
|||||||
|
|
||||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
|
||||||
printf("Headless server is now running...\n");
|
printf("Headless server is now running...\n");
|
||||||
|
printf("To shutdown type: quit\n");
|
||||||
|
printf("All commands require you to press ENTER\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//throw megaglest_runtime_error("Test!");
|
//throw megaglest_runtime_error("Test!");
|
||||||
@@ -5392,7 +5397,7 @@ int glestMain(int argc, char** argv) {
|
|||||||
printf("\nHeadless server is about to quit...\n");
|
printf("\nHeadless server is about to quit...\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] starting normal application shutdown\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] starting normal application shutdown\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||||
soundThreadManager = program->getSoundThreadManager(true);
|
soundThreadManager = program->getSoundThreadManager(true);
|
||||||
@@ -5404,11 +5409,11 @@ int glestMain(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanupCRCThread();
|
cleanupCRCThread();
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
showCursor(true);
|
showCursor(true);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
catch(const megaglest_runtime_error &e) {
|
catch(const megaglest_runtime_error &e) {
|
||||||
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
|
||||||
@@ -5475,25 +5480,25 @@ int glestMain(int argc, char** argv) {
|
|||||||
|
|
||||||
cleanupCRCThread();
|
cleanupCRCThread();
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//printf("Closing IRC CLient %d\n",__LINE__);
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
|
|
||||||
delete mainWindow;
|
delete mainWindow;
|
||||||
mainWindow = NULL;
|
mainWindow = NULL;
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//showCursor(true);
|
//showCursor(true);
|
||||||
//restoreVideoMode(true);
|
//restoreVideoMode(true);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
GraphicComponent::clearRegisteredComponents();
|
GraphicComponent::clearRegisteredComponents();
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//printf("Closing IRC CLient %d\n",__LINE__);
|
//printf("Closing IRC CLient %d\n",__LINE__);
|
||||||
|
|
||||||
@@ -5520,7 +5525,7 @@ int glestMain(int argc, char** argv) {
|
|||||||
#if defined(__GNUC__) && !defined(__FreeBSD__) && !defined(BSD)
|
#if defined(__GNUC__) && !defined(__FreeBSD__) && !defined(BSD)
|
||||||
void handleSIGSEGV(int sig) {
|
void handleSIGSEGV(int sig) {
|
||||||
char szBuf[8096]="";
|
char szBuf[8096]="";
|
||||||
snprintf(szBuf, 8096,"In [%s::%s Line: %d] Error detected: signal %d:\n",__FILE__,__FUNCTION__,__LINE__, sig);
|
snprintf(szBuf, 8096,"In [%s::%s Line: %d] Error detected: signal %d:\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__, sig);
|
||||||
printf("%s",szBuf);
|
printf("%s",szBuf);
|
||||||
//abort();
|
//abort();
|
||||||
|
|
||||||
@@ -5618,17 +5623,17 @@ __try {
|
|||||||
IRCThread::setGlobalCacheContainerName(GameConstants::ircClientCacheLookupKey);
|
IRCThread::setGlobalCacheContainerName(GameConstants::ircClientCacheLookupKey);
|
||||||
int result = glestMain(argc, argv);
|
int result = glestMain(argc, argv);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
cleanupProcessObjects();
|
cleanupProcessObjects();
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(sdl_quitCalled == false) {
|
if(sdl_quitCalled == false) {
|
||||||
sdl_quitCalled = true;
|
sdl_quitCalled = true;
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
return result;
|
return result;
|
||||||
#ifdef WIN32_STACK_TRACE
|
#ifdef WIN32_STACK_TRACE
|
||||||
} __except(stackdumper(0, GetExceptionInformation(),true), EXCEPTION_CONTINUE_SEARCH) { return 0; }
|
} __except(stackdumper(0, GetExceptionInformation(),true), EXCEPTION_CONTINUE_SEARCH) { return 0; }
|
||||||
|
@@ -61,6 +61,7 @@ private:
|
|||||||
bool deleteAfterExecute;
|
bool deleteAfterExecute;
|
||||||
static Mutex mutexthreadList;
|
static Mutex mutexthreadList;
|
||||||
static vector<Thread *> threadList;
|
static vector<Thread *> threadList;
|
||||||
|
static bool enableVerboseMode;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void addThreadToList();
|
void addThreadToList();
|
||||||
@@ -71,6 +72,9 @@ public:
|
|||||||
Thread();
|
Thread();
|
||||||
virtual ~Thread();
|
virtual ~Thread();
|
||||||
|
|
||||||
|
static void setEnableVerboseMode(bool value) { enableVerboseMode = value; }
|
||||||
|
static bool getEnableVerboseMode() { return enableVerboseMode; }
|
||||||
|
|
||||||
static std::vector<Thread *> getThreadList();
|
static std::vector<Thread *> getThreadList();
|
||||||
static void shutdownThreads();
|
static void shutdownThreads();
|
||||||
|
|
||||||
|
@@ -24,12 +24,20 @@ using namespace std;
|
|||||||
|
|
||||||
namespace Shared { namespace Platform {
|
namespace Shared { namespace Platform {
|
||||||
|
|
||||||
|
bool Thread::enableVerboseMode = false;
|
||||||
Mutex Thread::mutexthreadList;
|
Mutex Thread::mutexthreadList;
|
||||||
vector<Thread *> Thread::threadList;
|
vector<Thread *> Thread::threadList;
|
||||||
|
|
||||||
auto_ptr<Mutex> Mutex::mutexMutexList(new Mutex(CODE_AT_LINE));
|
auto_ptr<Mutex> Mutex::mutexMutexList(new Mutex(CODE_AT_LINE));
|
||||||
vector<Mutex *> Mutex::mutexList;
|
vector<Mutex *> Mutex::mutexList;
|
||||||
|
|
||||||
|
class ThreadGarbageCollector;
|
||||||
|
class Mutex;
|
||||||
|
class MutexSafeWrapper;
|
||||||
|
|
||||||
|
static auto_ptr<ThreadGarbageCollector> cleanupThread;
|
||||||
|
static auto_ptr<Mutex> cleanupThreadMutex(new Mutex());
|
||||||
|
|
||||||
class ThreadGarbageCollector : public BaseThread
|
class ThreadGarbageCollector : public BaseThread
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
@@ -41,34 +49,30 @@ protected:
|
|||||||
if(pendingCleanupList.empty() == false) {
|
if(pendingCleanupList.empty() == false) {
|
||||||
for(unsigned int index = 0; index < pendingCleanupList.size(); ++index) {
|
for(unsigned int index = 0; index < pendingCleanupList.size(); ++index) {
|
||||||
Thread *thread = pendingCleanupList[index];
|
Thread *thread = pendingCleanupList[index];
|
||||||
if(thread != NULL) {
|
cleanupPendingThread(thread);
|
||||||
BaseThread *base_thread = dynamic_cast<BaseThread *>(thread);
|
|
||||||
if(base_thread != NULL &&
|
|
||||||
(base_thread->getRunningStatus() == true || base_thread->getExecutingTask() == true)) {
|
|
||||||
sleep(10);
|
|
||||||
if(base_thread->getRunningStatus() == true || base_thread->getExecutingTask() == true) {
|
|
||||||
char szBuf[8096]="";
|
|
||||||
snprintf(szBuf,8095,"In [%s::%s Line: %d] cannot delete active thread: getRunningStatus(): %d getExecutingTask: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,base_thread->getRunningStatus(),base_thread->getExecutingTask());
|
|
||||||
throw megaglest_runtime_error(szBuf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
delete thread;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
pendingCleanupList.clear();
|
pendingCleanupList.clear();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ThreadGarbageCollector() : BaseThread() {
|
ThreadGarbageCollector() : BaseThread() {
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("In %s Line: %d this: %p\n",__FUNCTION__,__LINE__,this);
|
||||||
uniqueID = "ThreadGarbageCollector";
|
uniqueID = "ThreadGarbageCollector";
|
||||||
removeThreadFromList();
|
removeThreadFromList();
|
||||||
}
|
}
|
||||||
virtual ~ThreadGarbageCollector() {
|
virtual ~ThreadGarbageCollector() {
|
||||||
//printf("In ~ThreadAutoCleanup Line: %d\n",__LINE__);
|
if(Thread::getEnableVerboseMode()) {
|
||||||
|
printf("In %s Line: %d this: %p\n",__FUNCTION__,__LINE__,this);
|
||||||
|
string stack = PlatformExceptionHandler::getStackTrace();
|
||||||
|
printf("In %s Line: %d this: %p stack: %s\n",__FUNCTION__,__LINE__,this,stack.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
virtual void execute() {
|
virtual void execute() {
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("In %s Line: %d this: %p\n",__FUNCTION__,__LINE__,this);
|
||||||
|
|
||||||
RunningStatusSafeWrapper runningStatus(this);
|
RunningStatusSafeWrapper runningStatus(this);
|
||||||
for(;getQuitStatus() == false;) {
|
for(;getQuitStatus() == false;) {
|
||||||
if(cleanupPendingThreads() == false) {
|
if(cleanupPendingThreads() == false) {
|
||||||
@@ -77,16 +81,49 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("In %s Line: %d this: %p\n",__FUNCTION__,__LINE__,this);
|
||||||
|
|
||||||
cleanupPendingThreads();
|
cleanupPendingThreads();
|
||||||
|
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("In %s Line: %d this: %p\n",__FUNCTION__,__LINE__,this);
|
||||||
}
|
}
|
||||||
void addThread(Thread *thread) {
|
void addThread(Thread *thread) {
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("In %s Line: %d this: %p\n",__FUNCTION__,__LINE__,this);
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&mutexPendingCleanupList);
|
MutexSafeWrapper safeMutex(&mutexPendingCleanupList);
|
||||||
pendingCleanupList.push_back(thread);
|
pendingCleanupList.push_back(thread);
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("In %s Line: %d this: %p\n",__FUNCTION__,__LINE__,this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void cleanupPendingThread(Thread *thread) {
|
||||||
|
if(thread != NULL) {
|
||||||
|
BaseThread *base_thread = dynamic_cast<BaseThread *>(thread);
|
||||||
|
if(base_thread != NULL &&
|
||||||
|
(base_thread->getRunningStatus() == true || base_thread->getExecutingTask() == true)) {
|
||||||
|
sleep(10);
|
||||||
|
if(base_thread->getRunningStatus() == true || base_thread->getExecutingTask() == true) {
|
||||||
|
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("\n\n\n$$$$$$$$$$$$$$$$$$$$$$$$$$$ cleanupPendingThread Line: %d thread = %p [%s]\n",__LINE__,thread,(base_thread != NULL ? base_thread->getUniqueID().c_str() : "n/a"));
|
||||||
|
|
||||||
|
char szBuf[8096]="";
|
||||||
|
snprintf(szBuf,8095,"In [%s::%s Line: %d] cannot delete active thread: getRunningStatus(): %d getExecutingTask: %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,base_thread->getRunningStatus(),base_thread->getExecutingTask());
|
||||||
|
throw megaglest_runtime_error(szBuf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("!!!! cleanupPendingThread Line: %d thread = %p [%s]\n",__LINE__,thread,(base_thread != NULL ? base_thread->getUniqueID().c_str() : "n/a"));
|
||||||
|
|
||||||
|
delete thread;
|
||||||
|
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("!!!! cleanupPendingThread Line: %d thread = %p [%s]\n",__LINE__,thread,(base_thread != NULL ? base_thread->getUniqueID().c_str() : "n/a"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static auto_ptr<ThreadGarbageCollector> cleanupThread;
|
|
||||||
// =====================================
|
// =====================================
|
||||||
// Threads
|
// Threads
|
||||||
// =====================================
|
// =====================================
|
||||||
@@ -125,7 +162,7 @@ void Thread::shutdownThreads() {
|
|||||||
}
|
}
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
if(Thread::getEnableVerboseMode()) printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
if(cleanupThread.get() != 0) {
|
if(cleanupThread.get() != 0) {
|
||||||
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
sleep(0);
|
sleep(0);
|
||||||
@@ -139,24 +176,26 @@ void Thread::shutdownThreads() {
|
|||||||
}
|
}
|
||||||
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
//sleep(100);
|
//sleep(100);
|
||||||
|
|
||||||
|
MutexSafeWrapper safeMutex(cleanupThreadMutex.get());
|
||||||
cleanupThread.reset(0);
|
cleanupThread.reset(0);
|
||||||
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread::~Thread() {
|
Thread::~Thread() {
|
||||||
//printf("In ~Thread Line: %d [%p] thread = %p\n",__LINE__,this,thread);
|
if(Thread::getEnableVerboseMode()) printf("In ~Thread Line: %d [%p] thread = %p\n",__LINE__,this,thread);
|
||||||
|
|
||||||
if(thread != NULL) {
|
if(thread != NULL) {
|
||||||
SDL_WaitThread(thread, NULL);
|
SDL_WaitThread(thread, NULL);
|
||||||
thread = NULL;
|
thread = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//printf("In ~Thread Line: %d [%p] thread = %p\n",__LINE__,this,thread);
|
if(Thread::getEnableVerboseMode()) printf("In ~Thread Line: %d [%p] thread = %p\n",__LINE__,this,thread);
|
||||||
|
|
||||||
removeThreadFromList();
|
removeThreadFromList();
|
||||||
|
|
||||||
//printf("In ~Thread Line: %d [%p] thread = %p\n",__LINE__,this,thread);
|
if(Thread::getEnableVerboseMode()) printf("In ~Thread Line: %d [%p] thread = %p\n",__LINE__,this,thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Thread *> Thread::getThreadList() {
|
std::vector<Thread *> Thread::getThreadList() {
|
||||||
@@ -191,33 +230,81 @@ int Thread::beginExecution(void* data) {
|
|||||||
snprintf(szBuf,8095,"In [%s::%s Line: %d] thread == NULL",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
snprintf(szBuf,8095,"In [%s::%s Line: %d] thread == NULL",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
||||||
throw megaglest_runtime_error(szBuf);
|
throw megaglest_runtime_error(szBuf);
|
||||||
}
|
}
|
||||||
//printf("In Thread::execute Line: %d thread = %p\n",__LINE__,thread);
|
|
||||||
|
BaseThread *base_thread = dynamic_cast<BaseThread *>(thread);
|
||||||
|
ThreadGarbageCollector *garbage_collector = dynamic_cast<ThreadGarbageCollector *>(thread);
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("In Thread::execute Line: %d thread = %p base_thread = %p [%s]\n",__LINE__,thread,base_thread,(base_thread != NULL ? base_thread->getUniqueID().c_str() : "n/a"));
|
||||||
|
|
||||||
thread->execute();
|
thread->execute();
|
||||||
|
|
||||||
//printf("In Thread::execute Line: %d thread = %p\n",__LINE__,thread);
|
if(Thread::getEnableVerboseMode()) printf("In Thread::execute Line: %d thread = %p base_thread = %p [%s]\n",__LINE__,thread,base_thread,(base_thread != NULL ? base_thread->getUniqueID().c_str() : "n/a"));
|
||||||
|
|
||||||
thread->queueAutoCleanThread();
|
thread->queueAutoCleanThread();
|
||||||
|
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("In Thread::execute Line: %d\n",__LINE__);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread::queueAutoCleanThread() {
|
void Thread::queueAutoCleanThread() {
|
||||||
if(this->deleteAfterExecute == true) {
|
if(this->deleteAfterExecute == true) {
|
||||||
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
if(Thread::getEnableVerboseMode()) printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
|
|
||||||
|
BaseThread *base_thread = dynamic_cast<BaseThread *>(this);
|
||||||
|
ThreadGarbageCollector *garbage_collector = dynamic_cast<ThreadGarbageCollector *>(this);
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("In Thread::shutdownThreads Line: %d thread = %p base_thread = %p [%s]\n",__LINE__,this,base_thread,(base_thread != NULL ? base_thread->getUniqueID().c_str() : "n/a"));
|
||||||
|
|
||||||
|
MutexSafeWrapper safeMutex(cleanupThreadMutex.get());
|
||||||
if(cleanupThread.get() == NULL) {
|
if(cleanupThread.get() == NULL) {
|
||||||
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
if(Thread::getEnableVerboseMode()) printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
cleanupThread.reset(new ThreadGarbageCollector());
|
cleanupThread.reset(new ThreadGarbageCollector());
|
||||||
|
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
cleanupThread->start();
|
cleanupThread->start();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
safeMutex.ReleaseLock();
|
||||||
|
}
|
||||||
for(time_t elapsed = time(NULL);
|
for(time_t elapsed = time(NULL);
|
||||||
cleanupThread->getRunningStatus() == false &&
|
cleanupThread->getRunningStatus() == false &&
|
||||||
difftime(time(NULL),elapsed) < 6;) {
|
cleanupThread->getQuitStatus() == false &&
|
||||||
sleep(5);
|
difftime(time(NULL),elapsed) < 3;) {
|
||||||
}
|
sleep(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(cleanupThread->getQuitStatus() == true) {
|
||||||
|
//ThreadGarbageCollector::cleanupPendingThread(this);
|
||||||
|
if(cleanupThread->getRunningStatus() == false) {
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("MANUAL DELETE In Thread::shutdownThreads Line: %d this [%p]\n",__LINE__,this);
|
||||||
|
|
||||||
cleanupThread->addThread(this);
|
cleanupThread->addThread(this);
|
||||||
//printf("In Thread::shutdownThreads Line: %d\n",__LINE__);
|
cleanupThread->start();
|
||||||
|
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("MANUAL DELETE In Thread::shutdownThreads Line: %d\n",__LINE__);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("In Thread::shutdownThreads Line: %d this [%p]\n",__LINE__,this);
|
||||||
|
|
||||||
|
for(time_t elapsed = time(NULL);
|
||||||
|
cleanupThread->getRunningStatus() == true &&
|
||||||
|
cleanupThread->getQuitStatus() == true &&
|
||||||
|
difftime(time(NULL),elapsed) < 3;) {
|
||||||
|
sleep(0);
|
||||||
|
}
|
||||||
|
sleep(0);
|
||||||
|
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("In Thread::shutdownThreads Line: %d this [%p]\n",__LINE__,this);
|
||||||
|
|
||||||
|
cleanupThread->addThread(this);
|
||||||
|
cleanupThread->start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("In Thread::shutdownThreads Line: %d this [%p]\n",__LINE__,this);
|
||||||
|
cleanupThread->addThread(this);
|
||||||
|
}
|
||||||
|
if(Thread::getEnableVerboseMode()) printf("In Thread::shutdownThreads Line: %d this [%p]\n",__LINE__,this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user