]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/app.cpp
Docview mended (grrr) and OGL studio partially working under wxGTK
[wxWidgets.git] / src / msw / app.cpp
index bdd7b51a5283d5036d30214d1c99209eeeff7b08..8010fbf6dcbfac2799c8ab9e87e0be13fa7b6a37 100644 (file)
@@ -155,6 +155,18 @@ HBRUSH wxDisableButtonBrush = (HBRUSH) 0;
 
 LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM);
 
+// FIXME wxUSE_ON_FATAL_EXCEPTION is only supported for VC++ now because it
+//       needs compiler support for Win32 SEH. Others (especially Borland)
+//       probably have it too, but I'm not sure about how it works
+#ifndef __VISUALC__
+    #undef wxUSE_ON_FATAL_EXCEPTION
+    #define wxUSE_ON_FATAL_EXCEPTION 0
+#endif // VC++
+
+#if wxUSE_ON_FATAL_EXCEPTION
+    static bool gs_handleExceptions = FALSE;
+#endif
+
 // ===========================================================================
 // implementation
 // ===========================================================================
@@ -262,7 +274,7 @@ bool wxApp::Initialize()
 
     // This is to foil optimizations in Visual C++ that throw out dummy.obj.
     // PLEASE DO NOT ALTER THIS.
-#if defined(__VISUALC__) && !defined(WXMAKINGDLL)
+#if defined(__VISUALC__) && defined(__WIN16__) && !defined(WXMAKINGDLL)
     extern char wxDummyChar;
     if (wxDummyChar) wxDummyChar++;
 #endif
@@ -652,16 +664,11 @@ int wxEntry(WXHINSTANCE hInstance,
     wxDebugContext::SetCheckpoint();
 #endif
 #endif
-    // take everything into a try-except block in release build
-    // 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(__VISUALC__)
-    #define CATCH_PROGRAM_EXCEPTIONS
 
+    // take everything into a try-except block to be able to call
+    // OnFatalException() if necessary
+#if wxUSE_ON_FATAL_EXCEPTION
     __try {
-#else
-    #undef  CATCH_PROGRAM_EXCEPTIONS
 #endif
         wxhInstance = (HINSTANCE) hInstance;
 
@@ -734,13 +741,12 @@ int wxEntry(WXHINSTANCE hInstance,
 
         return retValue;
 
-#ifdef CATCH_PROGRAM_EXCEPTIONS
+#if wxUSE_ON_FATAL_EXCEPTION
     }
-    __except ( EXCEPTION_EXECUTE_HANDLER ) {
-        /*
-           if ( wxTheApp )
+    __except ( gs_handleExceptions ? EXCEPTION_EXECUTE_HANDLER
+                                   : EXCEPTION_CONTINUE_SEARCH ) {
+        if ( wxTheApp )
            wxTheApp->OnFatalException();
-         */
 
         // using wxLog would be unsafe here
         ::MessageBox(NULL,
@@ -753,7 +759,7 @@ int wxEntry(WXHINSTANCE hInstance,
 
         // NOTREACHED
     }
-#endif // CATCH_PROGRAM_EXCEPTIONS
+#endif // wxUSE_ON_FATAL_EXCEPTION
 }
 
 // restore warning state
@@ -837,8 +843,7 @@ bool wxApp::Initialized()
         return TRUE;
     else
         return FALSE;
-#endif
-#ifdef _WINDLL // Assume initialized if DLL (no way of telling)
+#else // Assume initialized if DLL (no way of telling)
     return TRUE;
 #endif
 }
@@ -1280,6 +1285,20 @@ bool wxYield()
     return TRUE;
 }
 
+bool wxHandleFatalExceptions(bool doit)
+{
+#if wxUSE_ON_FATAL_EXCEPTION
+    // assume this can only be called from the main thread
+    gs_handleExceptions = doit;
+
+    return TRUE;
+#else
+    wxFAIL_MSG(_T("set wxUSE_ON_FATAL_EXCEPTION to 1 to sue this function"));
+
+    return FALSE;
+#endif
+}
+
 //-----------------------------------------------------------------------------
 // wxWakeUpIdle
 //-----------------------------------------------------------------------------