]> git.saurik.com Git - wxWidgets.git/commitdiff
Add a system option to exit immediately on assert failure.
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 20 Jun 2010 17:43:21 +0000 (17:43 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 20 Jun 2010 17:43:21 +0000 (17:43 +0000)
This option will allow to test for absence of asserts in wxWidgets samples in
the future.

Closes #10697.

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

interface/wx/sysopt.h
src/common/appbase.cpp

index 2eef48cd48d91395ceec81c470878485222e65e7..3f5a4157c55127d01086eda30e382bd10b923f3c 100644 (file)
 
     These options are currently recognised by wxWidgets:
 
+    @section sysopt_all All platforms
+
+    @beginFlagTable
+    @flag{exit-on-assert}
+        If set to non-zero value, abort the program if an assertion fails. The
+        default behaviour in case of assertion failure depends on the build mode
+        and can be changed by overriding wxApp::OnAssertFailure() but setting
+        this option allows to change it without modifying the program code and
+        also applies to asserts which may happen before the wxApp object
+        creation or after its destruction.
+    @endFlagTable
 
     @section sysopt_win Windows
 
index 65231954924eb8ebda4e66d8c2cda625731ab722..36a65ef6e92442db0778acf8c99c51ad6420140b 100644 (file)
@@ -43,6 +43,7 @@
 #include "wx/filename.h"
 #include "wx/msgout.h"
 #include "wx/scopedptr.h"
+#include "wx/sysopt.h"
 #include "wx/tokenzr.h"
 #include "wx/thread.h"
 
@@ -1027,6 +1028,10 @@ wxDefaultAssertHandler(const wxString& file,
                        const wxString& cond,
                        const wxString& msg)
 {
+    // If this option is set, we should abort immediately when assert happens.
+    if ( wxSystemOptions::GetOptionInt("exit-on-assert") )
+        abort();
+
     // FIXME MT-unsafe
     static int s_bInAssert = 0;