fix lock, fix non working ASSERT when DEBUG is not defined
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Fri, 15 Dec 2006 16:16:49 +0000 (16:16 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Fri, 15 Dec 2006 16:16:49 +0000 (16:16 +0000)
lib/base/eerror.cpp
lib/base/eerror.h

index a84118793a91d377c9dfe7eeb6b390f261fb6edd..2182df49cd252bcddda810783cca571141ee0212 100644 (file)
@@ -1,4 +1,5 @@
 #include <lib/base/eerror.h>
+#include <lib/base/elock.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -6,8 +7,6 @@
 
 #include <string>
 
-// #include <lib/gui/emessage.h>
-
 #ifdef MEMLEAK_CHECK
 AllocList *allocList;
 pthread_mutex_t memLock =
@@ -67,16 +66,12 @@ void DumpUnfreed()
        printf("Total Unfreed: %d bytes\n", totalSize);
        fflush(stdout);
 };
-#else
-       #include <lib/base/elock.h>
 #endif
 
-int infatal=0;
-
 Signal2<void, int, const std::string&> logOutput;
-int logOutputConsole=1;
+int logOutputConsole=0;
 
-pthread_mutex_t signalLock =
+static pthread_mutex_t DebugLock =
        PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP;
 
 void eFatal(const char* fmt, ...)
@@ -86,18 +81,9 @@ void eFatal(const char* fmt, ...)
        va_start(ap, fmt);
        vsnprintf(buf, 1024, fmt, ap);
        va_end(ap);
-       singleLock s(signalLock);
+       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);
 }
 
@@ -109,7 +95,7 @@ void eDebug(const char* fmt, ...)
        va_start(ap, fmt);
        vsnprintf(buf, 1024, fmt, ap);
        va_end(ap);
-       singleLock s(signalLock);
+       singleLock s(DebugLock);
        logOutput(lvlDebug, std::string(buf) + "\n");
        if (logOutputConsole)
                fprintf(stderr, "%s\n", buf);
@@ -122,7 +108,7 @@ void eDebugNoNewLine(const char* fmt, ...)
        va_start(ap, fmt);
        vsnprintf(buf, 1024, fmt, ap);
        va_end(ap);
-       singleLock s(signalLock);
+       singleLock s(DebugLock);
        logOutput(lvlDebug, buf);
        if (logOutputConsole)
                fprintf(stderr, "%s", buf);
@@ -135,19 +121,20 @@ void eWarning(const char* fmt, ...)
        va_start(ap, fmt);
        vsnprintf(buf, 1024, fmt, ap);
        va_end(ap);
-       singleLock s(signalLock);
+       singleLock s(DebugLock);
        logOutput(lvlWarning, std::string(buf) + "\n");
        if (logOutputConsole)
                fprintf(stderr, "%s\n", buf);
 }
-#endif // DEBUG
 
 void ePythonOutput(const char *string)
 {
+       singleLock s(DebugLock);
        logOutput(lvlWarning, string);
        if (logOutputConsole)
                fwrite(string, 1, strlen(string), stderr);
 }
+#endif // DEBUG
 
 void eWriteCrashdump()
 {
index e7c33a0bb8d3dfb08d8abe0b8eff8bb54a4aee5f..2d4e979038d244f40ef1172f9324a52217f4b332 100644 (file)
@@ -135,13 +135,17 @@ enum { lvlDebug=1, lvlWarning=2, lvlFatal=4 };
     inline void eWarning(const char* fmt, ...)
     {
     }
-    #define ASSERT(x) do { } while (0)
+    #define ASSERT(x) do { x; } while (0)
 #endif //DEBUG
 
 void eWriteCrashdump();
 
 #endif // SWIG
 
-void ePythonOutput(const char *);
+#ifndef DEBUG
+inline void ePythonOutput(const char *)
+{
+}
+#endif
 
 #endif // __E_ERROR__