From 95a337349dacf00137e309a4b3ca6f3c14450ed6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 21 Aug 2021 15:25:17 +0200 Subject: [PATCH] Report errors in wxTestingModalHook in non-debug builds too wxFAIL_MSG_AT() does nothing in these builds, so do at least something else -- even if it's not ideal, it's still better than doing nothing. --- include/wx/testing.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/wx/testing.h b/include/wx/testing.h index 317040130b..63d578f004 100644 --- a/include/wx/testing.h +++ b/include/wx/testing.h @@ -34,6 +34,10 @@ class WXDLLIMPEXP_FWD_CORE wxFileDialogBase; #include "wx/msgdlg.h" #include "wx/filedlg.h" +#ifndef __WXDEBUG__ + #include "wx/crt.h" +#endif // !__WXDEBUG__ + #include class wxTestingModalHook; @@ -421,10 +425,20 @@ protected: // course, can itself be customized. virtual void ReportFailure(const wxString& msg) { +#ifdef __WXDEBUG__ wxFAIL_MSG_AT( msg, m_file ? m_file : __FILE__, m_line ? m_line : __LINE__, m_func ? m_func : __WXFUNCTION__ ); +#else // !__WXDEBUG__ + // We still need to report the failure somehow when wx asserts are + // disabled. + wxFprintf(stderr, wxASCII_STR("%s at %s:%d in %s()\n"), + msg, + wxASCII_STR(m_file ? m_file : __FILE__), + m_line ? m_line : __LINE__, + wxASCII_STR(m_func ? m_func : __WXFUNCTION__)); +#endif // __WXDEBUG__/!__WXDEBUG__ } private: