catches program exceptions in release build (VC++ only)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1385 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -87,16 +87,15 @@
|
|||||||
|
|
||||||
/* Need to undef new if including crtdbg.h */
|
/* Need to undef new if including crtdbg.h */
|
||||||
#ifdef new
|
#ifdef new
|
||||||
#undef new
|
#undef new
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <crtdbg.h>
|
#include <crtdbg.h>
|
||||||
|
|
||||||
#if defined(__WXDEBUG__) && wxUSE_GLOBAL_MEMORY_OPERATORS && wxUSE_DEBUG_NEW_ALWAYS
|
#if defined(__WXDEBUG__) && wxUSE_GLOBAL_MEMORY_OPERATORS && wxUSE_DEBUG_NEW_ALWAYS
|
||||||
#define new new(__FILE__,__LINE__)
|
#define new new(__FILE__,__LINE__)
|
||||||
#endif
|
#endif
|
||||||
|
#endif // wxUSE_VC_CRTDBG
|
||||||
#endif
|
|
||||||
|
|
||||||
extern char *wxBuffer;
|
extern char *wxBuffer;
|
||||||
extern char *wxOsVersion;
|
extern char *wxOsVersion;
|
||||||
@@ -563,6 +562,11 @@ void wxApp::CleanUp()
|
|||||||
|
|
||||||
#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
|
#if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
|
||||||
|
|
||||||
|
// temporarily disable this warning
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(disable: 4715) // not all control paths return a value
|
||||||
|
#endif // Visual C++
|
||||||
|
|
||||||
//// Main wxWindows entry point
|
//// Main wxWindows entry point
|
||||||
int wxEntry(WXHINSTANCE hInstance,
|
int wxEntry(WXHINSTANCE hInstance,
|
||||||
WXHINSTANCE WXUNUSED(hPrevInstance),
|
WXHINSTANCE WXUNUSED(hPrevInstance),
|
||||||
@@ -570,8 +574,16 @@ int wxEntry(WXHINSTANCE hInstance,
|
|||||||
int nCmdShow,
|
int nCmdShow,
|
||||||
bool enterLoop)
|
bool enterLoop)
|
||||||
{
|
{
|
||||||
#if !defined(__WXDEBUG__) && !defined(__BORLANDC__) && !defined(__WATCOMC__) // take everything into a try-except block in release build
|
// take everything into a try-except block in release build
|
||||||
try {
|
// FIXME other compilers must support Win32 SEH (structured exception
|
||||||
|
// handling) too, just find the appropriate keyword in their docs!
|
||||||
|
// Please note that it's _not_ the same as C++ exceptions!
|
||||||
|
#if !defined(__WXDEBUG__) && defined(_MSC_VER)
|
||||||
|
#define CATCH_PROGRAM_EXCEPTIONS
|
||||||
|
|
||||||
|
__try {
|
||||||
|
#else
|
||||||
|
#undef CATCH_PROGRAM_EXCEPTIONS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxhInstance = (HINSTANCE) hInstance;
|
wxhInstance = (HINSTANCE) hInstance;
|
||||||
@@ -640,20 +652,27 @@ int wxEntry(WXHINSTANCE hInstance,
|
|||||||
wxApp::CleanUp();
|
wxApp::CleanUp();
|
||||||
|
|
||||||
return retValue;
|
return retValue;
|
||||||
#if !defined(__WXDEBUG__) && !defined(__BORLANDC__) && !defined(__WATCOMC__) // catch exceptions only in release build
|
|
||||||
|
#ifdef CATCH_PROGRAM_EXCEPTIONS
|
||||||
}
|
}
|
||||||
except ( EXCEPTION_EXECUTE_HANDLER ) {
|
__except ( EXCEPTION_EXECUTE_HANDLER ) {
|
||||||
/*
|
/*
|
||||||
if ( wxTheApp )
|
if ( wxTheApp )
|
||||||
wxTheApp->OnFatalException();
|
wxTheApp->OnFatalException();
|
||||||
*/
|
*/
|
||||||
|
|
||||||
::ExitProcess(3); // the same exit code as abort()
|
::ExitProcess(3); // the same exit code as abort()
|
||||||
return 0;
|
|
||||||
|
// NOTREACHED
|
||||||
}
|
}
|
||||||
#endif //debug
|
#endif // CATCH_PROGRAM_EXCEPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// restore warning state
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#pragma warning(default: 4715) // not all control paths return a value
|
||||||
|
#endif // Visual C++
|
||||||
|
|
||||||
#else /* _WINDLL */
|
#else /* _WINDLL */
|
||||||
|
|
||||||
//// Entry point for DLLs
|
//// Entry point for DLLs
|
||||||
|
Reference in New Issue
Block a user