From: <man...@us...> - 2013-04-18 15:36:47
|
Revision: 1909 http://sourceforge.net/p/modplug/code/1909 Author: manxorist Date: 2013-04-18 15:36:38 +0000 (Thu, 18 Apr 2013) Log Message: ----------- [Ref] Move IsDebuggerPresent() logic of ALWAYS_ASSERT() into AlwaysAssertHandler function. Modified Paths: -------------- trunk/OpenMPT/common/typedefs.h trunk/OpenMPT/mptrack/ExceptionHandler.cpp Modified: trunk/OpenMPT/common/typedefs.h =================================================================== --- trunk/OpenMPT/common/typedefs.h 2013-04-18 15:22:56 UTC (rev 1908) +++ trunk/OpenMPT/common/typedefs.h 2013-04-18 15:36:38 UTC (rev 1909) @@ -59,13 +59,14 @@ #endif #define STATIC_ASSERT(expr) static_assert((expr), "compile time assertion failed: " #expr) +#ifdef NDEBUG void AlwaysAssertHandler(const char *file, int line, const char *function, const char *expr); -#ifdef NDEBUG -#define ALWAYS_ASSERT(expr) do { if(!(expr)) { if(IsDebuggerPresent()) { OutputDebugString("assert failed: " #expr); DebugBreak(); } else { AlwaysAssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr); } } } while(0) +#define ALWAYS_ASSERT(expr) do { if(!(expr)) { AlwaysAssertHandler(__FILE__, __LINE__, __FUNCTION__, #expr); } } while(0) #else #define ALWAYS_ASSERT(expr) ASSERT(expr) #endif + // Advanced inline attributes #if defined(_MSC_VER) #define forceinline __forceinline Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-04-18 15:22:56 UTC (rev 1908) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2013-04-18 15:36:38 UTC (rev 1909) @@ -144,10 +144,22 @@ } +#ifdef NDEBUG void AlwaysAssertHandler(const char *file, int line, const char *function, const char *expr) //------------------------------------------------------------------------------------------ { - CString errorMessage; - errorMessage.Format("Internal error occured at %s(%d): ASSERT(%s) failed in [%s].", file, line, expr, function); - GenerateDump(errorMessage); + if(IsDebuggerPresent()) + { + OutputDebugString("ASSERT("); + OutputDebugString(expr); + OutputDebugString(") failed\n"); + DebugBreak(); + } else + { + CString errorMessage; + errorMessage.Format("Internal error occured at %s(%d): ASSERT(%s) failed in [%s].", file, line, expr, function); + GenerateDump(errorMessage); + } } +#endif + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |