Don't show message boxes for assertion failures, since this can lead to crashes when in OnPaint

git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@1197 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
twanvl
2008-09-03 17:53:15 +00:00
parent 7c83ff01f4
commit 5d9c5fbf46
5 changed files with 64 additions and 7 deletions
+19
View File
@@ -12,6 +12,25 @@
DECLARE_TYPEOF_COLLECTION(ScriptParseError);
// ----------------------------------------------------------------------------- : Debug utilities
#if defined(_MSC_VER) && defined(_DEBUG)
void msvc_assert(const char* msg, const char* expr, const char* file, unsigned line) {
if (IsDebuggerPresent()) {
char buffer[1024];
if (msg) {
sprintf(buffer, "Assertion failed: %s: %s, file %s, line %d\n", msg, expr, file, line);
} else {
sprintf(buffer, "Assertion failed: %s, file %s, line %d\n", expr, file, line);
}
OutputDebugStringA(buffer);
DebugBreak();
} else {
_assert(expr, file, line);
}
}
#endif
// ----------------------------------------------------------------------------- : Error types
Error::Error(const String& message)
+14 -5
View File
@@ -80,12 +80,21 @@ class FileName : public wxString {
#include "reflect.hpp"
#include "regex.hpp"
// ----------------------------------------------------------------------------- : Debugging fixes
#ifdef _MSC_VER
//# pragma conform(forScope,on) // in "for(int x=..);" x goes out of scope after the for
// somehow forScope pragma doesn't work in precompiled headers, use this hack instead:
#ifdef _DEBUG
#define for if(false);else for
#endif
//# pragma conform(forScope,on) // in "for(int x=..);" x goes out of scope after the for
// somehow forScope pragma doesn't work in precompiled headers, use this hack instead:
#ifdef _DEBUG
#define for if(false);else for
#endif
#ifdef _DEBUG
// Use OutputDebugString/DebugBreak for assertions if in debug mode
void msvc_assert(const char*, const char*, const char*, unsigned);
#undef assert
#define assert(exp) (void)( (exp) || (msvc_assert(nullptr, #exp, __FILE__, __LINE__), 0) )
#endif
#endif
// ----------------------------------------------------------------------------- : EOF
+6
View File
@@ -54,6 +54,9 @@
}
};
inline Regex() {}
inline Regex(const String& code) { assign(code); }
void assign(const String& code);
inline bool matches(const String& str) const {
return regex_search(str.begin(), str.end(), regex);
@@ -126,6 +129,9 @@
friend class ScriptRegex;
};
inline Regex() {}
inline Regex(const String& code) { assign(code); }
void assign(const String& code);
inline bool matches(const String& str) const {
return regex.Matches(str);