]> git.saurik.com Git - wxWidgets.git/commitdiff
Override OnAssertFailure() and not deprecated OnAssert() in except sample.
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 9 Dec 2009 14:58:56 +0000 (14:58 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 9 Dec 2009 14:58:56 +0000 (14:58 +0000)
Also make the overridden version more interesting instead of just calling the
base class method from it.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62840 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/except/except.cpp

index ed04aec596c17f77cf6ba0d16772d628691edc38..db66fb76de4b7be935a1eeac25e660b06ad73d35 100644 (file)
@@ -91,14 +91,13 @@ public:
     // crash (e.g. dereferencing null pointer, division by 0, ...)
     virtual void OnFatalException();
 
-#ifdef __WXDEBUG__
-    // in debug mode, you can override this function to do something different
-    // (e.g. log the assert to file) whenever an assertion fails
-    virtual void OnAssert(const wxChar *file,
-                          int line,
-                          const wxChar *cond,
-                          const wxChar *msg);
-#endif // __WXDEBUG__
+    // you can override this function to do something different (e.g. log the
+    // assert to file) whenever an assertion fails
+    virtual void OnAssertFailure(const wxChar *file,
+                                 int line,
+                                 const wxChar *func,
+                                 const wxChar *cond,
+                                 const wxChar *msg);
 };
 
 // Define a new frame type: this is going to be our main frame
@@ -302,19 +301,25 @@ void MyApp::OnFatalException()
                  wxT("wxExcept Sample"), wxOK | wxICON_ERROR);
 }
 
-#ifdef __WXDEBUG__
-
-void MyApp::OnAssert(const wxChar *file,
-                     int line,
-                     const wxChar *cond,
-                     const wxChar *msg)
+void MyApp::OnAssertFailure(const wxChar *file,
+                            int line,
+                            const wxChar *func,
+                            const wxChar *cond,
+                            const wxChar *msg)
 {
-    // we don't have anything special to do here
-    wxApp::OnAssert(file, line, cond, msg);
+    if ( wxMessageBox
+         (
+            wxString::Format("An assert failed in %s().", func) +
+            "\n"
+            "Do you want to call the default assert handler?",
+            "wxExcept Sample",
+            wxYES_NO | wxICON_QUESTION
+         ) == wxYES )
+    {
+        wxApp::OnAssertFailure(file, line, func, cond, msg);
+    }
 }
 
-#endif // __WXDEBUG__
-
 // ============================================================================
 // MyFrame implementation
 // ============================================================================