git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15827
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
a function returning a pointer would stop compiling now (but this change
is not supposed to have any effects on valid code)
a function returning a pointer would stop compiling now (but this change
is not supposed to have any effects on valid code)
+- another minor change: wxApp::OnAssert() has a new "cond" argument, you
+ must modify YourApp::OnAssert() signature if you were using it to override
+ the default assert handling.
+
All (GUI):
! the event type constants are not constants any more but are dynamically
All (GUI):
! the event type constants are not constants any more but are dynamically
\membersection{wxApp::OnAssert}\label{wxapponassert}
\membersection{wxApp::OnAssert}\label{wxapponassert}
-\func{void}{OnAssert}{\param{const wxChar }{*file}, \param{int }{line}, \param{const wxChar }{*msg}}
+\func{void}{OnAssert}{\param{const wxChar }{*file}, \param{int }{line}, \param{const wxChar }{*cond}, \param{const wxChar }{*msg}}
This function is called when an assert failure occurs, i.e. the condition
specified in \helpref{wxASSERT}{wxassert} macro evaluated to {\tt FALSE}.
This function is called when an assert failure occurs, i.e. the condition
specified in \helpref{wxASSERT}{wxassert} macro evaluated to {\tt FALSE}.
\docparam{line}{the line number in this file where the assert occured}
\docparam{line}{the line number in this file where the assert occured}
+\docparam{cond}{the condition of the failed assert in string form}
+
\docparam{msg}{the message specified as argument to
\helpref{wxASSERT\_MSG}{wxassertmsg} or \helpref{wxFAIL\_MSG}{wxfailmsg}, will
be {\tt NULL} if just \helpref{wxASSERT}{wxassert} or \helpref{wxFAIL}{wxfail}
\docparam{msg}{the message specified as argument to
\helpref{wxASSERT\_MSG}{wxassertmsg} or \helpref{wxFAIL\_MSG}{wxfailmsg}, will
be {\tt NULL} if just \helpref{wxASSERT}{wxassert} or \helpref{wxFAIL}{wxfail}
\membersection{::wxOnAssert}\label{wxonassert}
\membersection{::wxOnAssert}\label{wxonassert}
-\func{void}{wxOnAssert}{\param{const char *}{fileName}, \param{int}{ lineNumber}, \param{const char *}{msg = NULL}}
+\func{void}{wxOnAssert}{\param{const char *}{fileName}, \param{int}{ lineNumber}, \param{const char *}{cond}, \param{const char *}{msg = NULL}}
This function is called whenever one of debugging macros fails (i.e. condition
is false in an assertion). It is only defined in the debug mode, in release
This function is called whenever one of debugging macros fails (i.e. condition
is false in an assertion). It is only defined in the debug mode, in release
// this function is called when an assert failure occurs, the base class
// version does the normal processing (i.e. shows the usual assert failure
// dialog box)
// this function is called when an assert failure occurs, the base class
// version does the normal processing (i.e. shows the usual assert failure
// dialog box)
+ //
+ // the arguments are the place where the assert occured, the text of the
+ // assert itself and the user-specified message
- virtual void OnAssert(const wxChar *file, int line, const wxChar *msg);
+ virtual void OnAssert(const wxChar *file,
+ int line,
+ const wxChar *cond,
+ const wxChar *msg);
#endif // __WXDEBUG__
// check that the wxBuildOptions object (constructed in the application
#endif // __WXDEBUG__
// check that the wxBuildOptions object (constructed in the application
*/
extern void WXDLLEXPORT wxOnAssert(const wxChar *szFile,
int nLine,
*/
extern void WXDLLEXPORT wxOnAssert(const wxChar *szFile,
int nLine,
const wxChar *szMsg = NULL);
// call this function to break into the debugger uncodnitionally (assuming
// the program is running under debugger, of course)
extern void WXDLLEXPORT wxTrap();
const wxChar *szMsg = NULL);
// call this function to break into the debugger uncodnitionally (assuming
// the program is running under debugger, of course)
extern void WXDLLEXPORT wxTrap();
- /*
- notice the usage of else at the end of wxASSERT macro: this ensures that
- the following code
-
- if ( ... )
- wxASSERT(...);
- else
- ...
-
- works like expected: if there were no "else", the one in the code above
- would be matched with a wrong "if"
- */
+ // helper function used to implement wxASSERT and wxASSERT_MSG
+ //
+ // note using "int" and not "bool" for cond to avoid VC++ warnings about
+ // implicit conversions when doing "wxAssert( pointer )" and also use of
+ // "!!cond" below to ensure that everything is converted to int
+ inline void WXDLLEXPORT wxAssert(int cond,
+ const wxChar *szFile,
+ int nLine,
+ const wxChar *szCond,
+ const wxChar *szMsg = NULL)
+ {
+ if ( !cond )
+ wxOnAssert(szFile, nLine, szCond, szMsg);
+ }
- #define wxASSERT(cond) if ( !(cond) ) wxOnAssert(__TFILE__, __LINE__); else
+ #define wxASSERT(cond) wxAssert(!!(cond), __TFILE__, __LINE__, _T(#cond))
// assert with additional message explaining it's cause
#define wxASSERT_MSG(cond, msg) \
// assert with additional message explaining it's cause
#define wxASSERT_MSG(cond, msg) \
- if ( !(cond) ) wxOnAssert(__TFILE__, __LINE__, msg); else
+ wxAssert(!!(cond), __TFILE__, __LINE__, _T(#cond), msg)
// an assert helper used to avoid warning when testing constant expressions,
// i.e. wxASSERT( sizeof(int) == 4 ) can generate a compiler warning about
// expression being always true, but not using
// wxASSERT( wxAssertIsEqual(sizeof(int), 4) )
// an assert helper used to avoid warning when testing constant expressions,
// i.e. wxASSERT( sizeof(int) == 4 ) can generate a compiler warning about
// expression being always true, but not using
// wxASSERT( wxAssertIsEqual(sizeof(int), 4) )
+ //
+ // NB: this is made obsolete by wxCOMPILE_TIME_ASSERT() and shouldn't be
+ // used any longer
extern bool WXDLLEXPORT wxAssertIsEqual(int x, int y);
#else
#define wxTrap()
extern bool WXDLLEXPORT wxAssertIsEqual(int x, int y);
#else
#define wxTrap()
// show the assert modal dialog
static
// show the assert modal dialog
static
-void ShowAssertDialog(const wxChar *szFile, int nLine, const wxChar *szMsg)
+void ShowAssertDialog(const wxChar *szFile,
+ int nLine,
+ const wxChar *szCond,
+ const wxChar *szMsg)
{
// this variable can be set to true to suppress "assert failure" messages
static bool s_bNoAsserts = FALSE;
wxChar szBuf[4096];
{
// this variable can be set to true to suppress "assert failure" messages
static bool s_bNoAsserts = FALSE;
wxChar szBuf[4096];
- // make life easier for people using VC++ IDE: clicking on the message
- // will take us immediately to the place of the failed assert
+ // make life easier for people using VC++ IDE by using this format: like
+ // this, clicking on the message will take us immediately to the place of
+ // the failed assert
wxSnprintf(szBuf, WXSIZEOF(szBuf),
wxSnprintf(szBuf, WXSIZEOF(szBuf),
-#ifdef __VISUALC__
- wxT("%s(%d): assert failed"),
-#else // !VC++
- // make the error message more clear for all the others
- wxT("Assert failed in file %s at line %d"),
-#endif // VC/!VC
- szFile, nLine);
+ wxT("%s(%d): assert \"%s\" failed"),
+ szFile, nLine, szCond);
}
// this function is called when an assert fails
}
// this function is called when an assert fails
-void wxOnAssert(const wxChar *szFile, int nLine, const wxChar *szMsg)
+void wxOnAssert(const wxChar *szFile,
+ int nLine,
+ const wxChar *szCond,
+ const wxChar *szMsg)
{
// FIXME MT-unsafe
static bool s_bInAssert = FALSE;
{
// FIXME MT-unsafe
static bool s_bInAssert = FALSE;
{
// by default, show the assert dialog box - we can't customize this
// behaviour
{
// by default, show the assert dialog box - we can't customize this
// behaviour
- ShowAssertDialog(szFile, nLine, szMsg);
+ ShowAssertDialog(szFile, nLine, szCond, szMsg);
}
else
{
// let the app process it as it wants
}
else
{
// let the app process it as it wants
- wxTheApp->OnAssert(szFile, nLine, szMsg);
+ wxTheApp->OnAssert(szFile, nLine, szCond, szMsg);
-void wxAppBase::OnAssert(const wxChar *file, int line, const wxChar *msg)
+void wxAppBase::OnAssert(const wxChar *file,
+ int line,
+ const wxChar *cond,
+ const wxChar *msg)
- ShowAssertDialog(file, line, msg);
+ ShowAssertDialog(file, line, cond, msg);