X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/13d05b593618882cfc356aef47a4a02fcb857271..14490ab8fe9c3eeb2e9f40da4b2e70f519357e63:/lib/base/eerror.cpp diff --git a/lib/base/eerror.cpp b/lib/base/eerror.cpp index 3fc38ade..8766f5ec 100644 --- a/lib/base/eerror.cpp +++ b/lib/base/eerror.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -6,8 +7,6 @@ #include -// #include - #ifdef MEMLEAK_CHECK AllocList *allocList; pthread_mutex_t memLock = @@ -67,15 +66,16 @@ void DumpUnfreed() printf("Total Unfreed: %d bytes\n", totalSize); fflush(stdout); }; -#else - #include #endif -int infatal=0; - Signal2 logOutput; int logOutputConsole=1; +static pthread_mutex_t DebugLock = + PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP; + +extern void bsodFatal(); + void eFatal(const char* fmt, ...) { char buf[1024]; @@ -83,19 +83,10 @@ void eFatal(const char* fmt, ...) va_start(ap, fmt); vsnprintf(buf, 1024, fmt, ap); va_end(ap); + singleLock s(DebugLock); logOutput(lvlFatal, buf); fprintf(stderr, "FATAL: %s\n",buf ); -#if 0 - if (!infatal) - { - infatal=1; - eMessageBox msg(buf, "FATAL ERROR", eMessageBox::iconError|eMessageBox::btOK); - msg.show(); - msg.exec(); - } -#endif - - _exit(0); + bsodFatal(); } #ifdef DEBUG @@ -106,6 +97,7 @@ void eDebug(const char* fmt, ...) va_start(ap, fmt); vsnprintf(buf, 1024, fmt, ap); va_end(ap); + singleLock s(DebugLock); logOutput(lvlDebug, std::string(buf) + "\n"); if (logOutputConsole) fprintf(stderr, "%s\n", buf); @@ -118,6 +110,7 @@ void eDebugNoNewLine(const char* fmt, ...) va_start(ap, fmt); vsnprintf(buf, 1024, fmt, ap); va_end(ap); + singleLock s(DebugLock); logOutput(lvlDebug, buf); if (logOutputConsole) fprintf(stderr, "%s", buf); @@ -130,6 +123,7 @@ void eWarning(const char* fmt, ...) va_start(ap, fmt); vsnprintf(buf, 1024, fmt, ap); va_end(ap); + singleLock s(DebugLock); logOutput(lvlWarning, std::string(buf) + "\n"); if (logOutputConsole) fprintf(stderr, "%s\n", buf); @@ -138,9 +132,12 @@ void eWarning(const char* fmt, ...) void ePythonOutput(const char *string) { +#ifdef DEBUG + singleLock s(DebugLock); logOutput(lvlWarning, string); if (logOutputConsole) fwrite(string, 1, strlen(string), stderr); +#endif } void eWriteCrashdump()