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
@@ -46,6 +46,10 @@ class MSE : public wxApp {
int OnExit();
/// On exception: display error message
bool OnExceptionInMainLoop();
/// Fancier assert
#if defined(_MSC_VER) && defined(_DEBUG)
void OnAssert(const wxChar *file, int line, const wxChar *cond, const wxChar *msg);
#endif
};
IMPLEMENT_APP(MSE)
@@ -265,3 +269,18 @@ bool MSE::OnExceptionInMainLoop() {
} CATCH_ALL_ERRORS(true);
return true;
}
#if defined(_MSC_VER) && defined(_DEBUG)
// Print assert failures to debug output
void msvc_assert(const char*, const char*, const char*, unsigned);
void MSE::OnAssert(const wxChar *file, int line, const wxChar *cond, const wxChar *msg) {
#ifdef UNICODE
char file_[1024]; wcstombs(file_,file,1023);
char cond_[1024]; wcstombs(cond_,cond,1023);
char msg_ [1024]; wcstombs(msg_, msg, 1023);
msvc_assert(msg_, cond_, file_, line);
#else
msvc_assert(msg, cond, file, line);
#endif
}
#endif