From 4d1ea475c8566b21777045285c5f1cfa2cc7b7cf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 20 Jun 2010 17:43:21 +0000 Subject: [PATCH] Add a system option to exit immediately on assert failure. 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 | 11 +++++++++++ src/common/appbase.cpp | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/interface/wx/sysopt.h b/interface/wx/sysopt.h index 2eef48cd48..3f5a4157c5 100644 --- a/interface/wx/sysopt.h +++ b/interface/wx/sysopt.h @@ -28,6 +28,17 @@ 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 diff --git a/src/common/appbase.cpp b/src/common/appbase.cpp index 6523195492..36a65ef6e9 100644 --- a/src/common/appbase.cpp +++ b/src/common/appbase.cpp @@ -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; -- 2.49.0